Expander: Check Window()->Lock() return value

This commit is contained in:
John Scipione 2014-06-09 15:41:36 -04:00
parent 1e35cfaea2
commit 122abe4315

View File

@ -64,8 +64,7 @@ DirectoryFilePanel::DirectoryFilePanel(file_panel_mode mode,
void
DirectoryFilePanel::Show()
{
if (fCurrentButton == NULL) {
Window()->Lock();
if (fCurrentButton == NULL && Window()->Lock()) {
BView* background = Window()->ChildAt(0);
BView* cancel = background->FindView("cancel button");
@ -105,22 +104,23 @@ DirectoryFilePanel::Show()
void
DirectoryFilePanel::SelectionChanged()
{
Window()->Lock();
// Resize button so that the label fits
// maximum width is dictated by the window's size limits
if (Window()->Lock()) {
float dummy;
float maxWidth;
Window()->GetSizeLimits(&maxWidth, &dummy, &dummy, &dummy);
maxWidth -= Window()->Bounds().Width() + 8 - fCurrentButton->Frame().right;
maxWidth -= Window()->Bounds().Width() + 8
- fCurrentButton->Frame().right;
BRect oldBounds = fCurrentButton->Bounds();
char* label;
entry_ref ref;
GetPanelDirectory(&ref);
asprintf(&label, B_TRANSLATE("Select '%s'" B_UTF8_ELLIPSIS), ref.name);
asprintf(&label, B_TRANSLATE("Select '%s'" B_UTF8_ELLIPSIS),
ref.name);
fCurrentButton->SetLabel(label);
free(label);
@ -134,6 +134,7 @@ DirectoryFilePanel::SelectionChanged()
fCurrentButton->MoveBy(oldBounds.Width() - width, 0);
Window()->Unlock();
}
BFilePanel::SelectionChanged();
}