Fix decorator reload crash.

- SetTopTap() -> SetTopTab().
- When reloading the decor, if the window in question is borderless,
  short circuit. Previously, we wouldn't allocate a decorator for such
  a window, but would then go through the remaining steps of attempting
  to set the focus/top tab, which would obviously crash. Fixes #8500 and
  possibly others.
- Add error check that adding tabs to the decorator actually succeeded.
This commit is contained in:
Rene Gollent
2012-04-28 16:21:19 -04:00
parent 2f2f3fa042
commit 03b82a629d
3 changed files with 15 additions and 11 deletions
+10 -6
View File
@@ -602,10 +602,14 @@ Window::ReloadDecor()
Window* window = stack->WindowAt(i); Window* window = stack->WindowAt(i);
BRegion dirty; BRegion dirty;
DesktopSettings settings(fDesktop); DesktopSettings settings(fDesktop);
decorator->AddTab(settings, window->Title(), window->Look(), if (decorator->AddTab(settings, window->Title(), window->Look(),
window->Flags(), -1, &dirty); window->Flags(), -1, &dirty) == NULL) {
delete decorator;
return false;
}
} }
} } else
return true;
windowBehaviour = gDecorManager.AllocateWindowBehaviour(this); windowBehaviour = gDecorManager.AllocateWindowBehaviour(this);
if (windowBehaviour == NULL) { if (windowBehaviour == NULL) {
@@ -624,7 +628,7 @@ Window::ReloadDecor()
if (window->IsFocus()) if (window->IsFocus())
decorator->SetFocus(i, true); decorator->SetFocus(i, true);
if (window == stack->TopLayerWindow()) if (window == stack->TopLayerWindow())
decorator->SetTopTap(i); decorator->SetTopTab(i);
} }
return true; return true;
@@ -2111,7 +2115,7 @@ Window::DetachFromWindowStack(bool ownStackNeeded)
::Decorator* decorator = fCurrentStack->Decorator(); ::Decorator* decorator = fCurrentStack->Decorator();
if (decorator != NULL) { if (decorator != NULL) {
decorator->RemoveTab(index); decorator->RemoveTab(index);
decorator->SetTopTap(fCurrentStack->LayerOrder().CountItems() - 1); decorator->SetTopTab(fCurrentStack->LayerOrder().CountItems() - 1);
} }
Window* remainingTop = fCurrentStack->TopLayerWindow(); Window* remainingTop = fCurrentStack->TopLayerWindow();
@@ -2230,7 +2234,7 @@ Window::MoveToTopStackLayer()
return false; return false;
decorator->SetDrawingEngine(fDrawingEngine); decorator->SetDrawingEngine(fDrawingEngine);
SetLook(Look(), NULL); SetLook(Look(), NULL);
decorator->SetTopTap(PositionInStack()); decorator->SetTopTab(PositionInStack());
return fCurrentStack->MoveToTopLayer(this); return fCurrentStack->MoveToTopLayer(this);
} }
+1 -1
View File
@@ -159,7 +159,7 @@ Decorator::TabAt(const BPoint& where) const
void void
Decorator::SetTopTap(int32 tab) Decorator::SetTopTab(int32 tab)
{ {
fTopTab = fTabList.ItemAt(tab); fTopTab = fTabList.ItemAt(tab);
} }
+1 -1
View File
@@ -93,7 +93,7 @@ public:
{ return fTabList.ItemAt(index); } { return fTabList.ItemAt(index); }
int32 CountTabs() const int32 CountTabs() const
{ return fTabList.CountItems(); } { return fTabList.CountItems(); }
void SetTopTap(int32 tab); void SetTopTab(int32 tab);
void SetDrawingEngine(DrawingEngine *driver); void SetDrawingEngine(DrawingEngine *driver);
inline DrawingEngine* GetDrawingEngine() const inline DrawingEngine* GetDrawingEngine() const