From 03b82a629d6358fc6c4ad3b5bb45793fd028a0f2 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sat, 28 Apr 2012 16:18:46 -0400 Subject: [PATCH] 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. --- src/servers/app/Window.cpp | 18 +++++++++++------- src/servers/app/decorator/Decorator.cpp | 4 ++-- src/servers/app/decorator/Decorator.h | 4 ++-- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/servers/app/Window.cpp b/src/servers/app/Window.cpp index 4f2ca6e824..ffc7556b00 100644 --- a/src/servers/app/Window.cpp +++ b/src/servers/app/Window.cpp @@ -602,10 +602,14 @@ Window::ReloadDecor() Window* window = stack->WindowAt(i); BRegion dirty; DesktopSettings settings(fDesktop); - decorator->AddTab(settings, window->Title(), window->Look(), - window->Flags(), -1, &dirty); + if (decorator->AddTab(settings, window->Title(), window->Look(), + window->Flags(), -1, &dirty) == NULL) { + delete decorator; + return false; + } } - } + } else + return true; windowBehaviour = gDecorManager.AllocateWindowBehaviour(this); if (windowBehaviour == NULL) { @@ -624,7 +628,7 @@ Window::ReloadDecor() if (window->IsFocus()) decorator->SetFocus(i, true); if (window == stack->TopLayerWindow()) - decorator->SetTopTap(i); + decorator->SetTopTab(i); } return true; @@ -2111,7 +2115,7 @@ Window::DetachFromWindowStack(bool ownStackNeeded) ::Decorator* decorator = fCurrentStack->Decorator(); if (decorator != NULL) { decorator->RemoveTab(index); - decorator->SetTopTap(fCurrentStack->LayerOrder().CountItems() - 1); + decorator->SetTopTab(fCurrentStack->LayerOrder().CountItems() - 1); } Window* remainingTop = fCurrentStack->TopLayerWindow(); @@ -2230,7 +2234,7 @@ Window::MoveToTopStackLayer() return false; decorator->SetDrawingEngine(fDrawingEngine); SetLook(Look(), NULL); - decorator->SetTopTap(PositionInStack()); + decorator->SetTopTab(PositionInStack()); return fCurrentStack->MoveToTopLayer(this); } @@ -2248,7 +2252,7 @@ Window::MoveToStackPosition(int32 to, bool isMoving) ::Decorator* decorator = Decorator(); if (decorator && decorator->MoveTab(index, to, isMoving, &dirty) == false) return false; - + fDesktop->RebuildAndRedrawAfterWindowChange(this, dirty); return true; } diff --git a/src/servers/app/decorator/Decorator.cpp b/src/servers/app/decorator/Decorator.cpp index 263da1968c..1bd90bb4b2 100644 --- a/src/servers/app/decorator/Decorator.cpp +++ b/src/servers/app/decorator/Decorator.cpp @@ -159,7 +159,7 @@ Decorator::TabAt(const BPoint& where) const void -Decorator::SetTopTap(int32 tab) +Decorator::SetTopTab(int32 tab) { fTopTab = fTabList.ItemAt(tab); } @@ -404,7 +404,7 @@ Decorator::SetTabLocation(int32 tab, float location, bool isShifting, return false; } - + /*! \brief Changes the focus value of the decorator diff --git a/src/servers/app/decorator/Decorator.h b/src/servers/app/decorator/Decorator.h index f444a0b9bd..40c740da9b 100644 --- a/src/servers/app/decorator/Decorator.h +++ b/src/servers/app/decorator/Decorator.h @@ -89,11 +89,11 @@ public: virtual bool MoveTab(int32 from, int32 to, bool isMoving, BRegion* updateRegion = NULL); virtual int32 TabAt(const BPoint& where) const; - Decorator::Tab* TabAt(int32 index) const + Decorator::Tab* TabAt(int32 index) const { return fTabList.ItemAt(index); } int32 CountTabs() const { return fTabList.CountItems(); } - void SetTopTap(int32 tab); + void SetTopTab(int32 tab); void SetDrawingEngine(DrawingEngine *driver); inline DrawingEngine* GetDrawingEngine() const