Expander: Check Window()->Lock() return value
This commit is contained in:
parent
1e35cfaea2
commit
122abe4315
@ -64,8 +64,7 @@ DirectoryFilePanel::DirectoryFilePanel(file_panel_mode mode,
|
|||||||
void
|
void
|
||||||
DirectoryFilePanel::Show()
|
DirectoryFilePanel::Show()
|
||||||
{
|
{
|
||||||
if (fCurrentButton == NULL) {
|
if (fCurrentButton == NULL && Window()->Lock()) {
|
||||||
Window()->Lock();
|
|
||||||
BView* background = Window()->ChildAt(0);
|
BView* background = Window()->ChildAt(0);
|
||||||
BView* cancel = background->FindView("cancel button");
|
BView* cancel = background->FindView("cancel button");
|
||||||
|
|
||||||
@ -105,35 +104,37 @@ DirectoryFilePanel::Show()
|
|||||||
void
|
void
|
||||||
DirectoryFilePanel::SelectionChanged()
|
DirectoryFilePanel::SelectionChanged()
|
||||||
{
|
{
|
||||||
Window()->Lock();
|
|
||||||
|
|
||||||
// Resize button so that the label fits
|
// Resize button so that the label fits
|
||||||
// maximum width is dictated by the window's size limits
|
// maximum width is dictated by the window's size limits
|
||||||
|
|
||||||
float dummy;
|
if (Window()->Lock()) {
|
||||||
float maxWidth;
|
float dummy;
|
||||||
Window()->GetSizeLimits(&maxWidth, &dummy, &dummy, &dummy);
|
float maxWidth;
|
||||||
maxWidth -= Window()->Bounds().Width() + 8 - fCurrentButton->Frame().right;
|
Window()->GetSizeLimits(&maxWidth, &dummy, &dummy, &dummy);
|
||||||
|
maxWidth -= Window()->Bounds().Width() + 8
|
||||||
|
- fCurrentButton->Frame().right;
|
||||||
|
|
||||||
BRect oldBounds = fCurrentButton->Bounds();
|
BRect oldBounds = fCurrentButton->Bounds();
|
||||||
|
|
||||||
char* label;
|
char* label;
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
GetPanelDirectory(&ref);
|
GetPanelDirectory(&ref);
|
||||||
asprintf(&label, B_TRANSLATE("Select '%s'" B_UTF8_ELLIPSIS), ref.name);
|
asprintf(&label, B_TRANSLATE("Select '%s'" B_UTF8_ELLIPSIS),
|
||||||
fCurrentButton->SetLabel(label);
|
ref.name);
|
||||||
free(label);
|
fCurrentButton->SetLabel(label);
|
||||||
|
free(label);
|
||||||
|
|
||||||
float width;
|
float width;
|
||||||
float height;
|
float height;
|
||||||
fCurrentButton->GetPreferredSize(&width, &height);
|
fCurrentButton->GetPreferredSize(&width, &height);
|
||||||
if (width > maxWidth)
|
if (width > maxWidth)
|
||||||
width = maxWidth;
|
width = maxWidth;
|
||||||
|
|
||||||
fCurrentButton->ResizeTo(width, oldBounds.Height());
|
fCurrentButton->ResizeTo(width, oldBounds.Height());
|
||||||
fCurrentButton->MoveBy(oldBounds.Width() - width, 0);
|
fCurrentButton->MoveBy(oldBounds.Width() - width, 0);
|
||||||
|
|
||||||
Window()->Unlock();
|
Window()->Unlock();
|
||||||
|
}
|
||||||
|
|
||||||
BFilePanel::SelectionChanged();
|
BFilePanel::SelectionChanged();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user