From d240743e9be7d720aadedd5a0185a61a907bca74 Mon Sep 17 00:00:00 2001 From: czeidler Date: Tue, 29 Nov 2011 10:30:42 +1300 Subject: [PATCH] - The SATGroup has been deleted to early, that probably causes #8103. Holding a reference on the WindowArea (which hold a ref to the group) extends the lifetime till we are done. - Fix some stayBelowMouse flags. --- src/servers/app/stackandtile/SATGroup.cpp | 12 +++++------- src/servers/app/stackandtile/SATWindow.cpp | 3 ++- src/servers/app/stackandtile/StackAndTile.cpp | 6 +++--- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/servers/app/stackandtile/SATGroup.cpp b/src/servers/app/stackandtile/SATGroup.cpp index beb1459ed4..08b757786b 100644 --- a/src/servers/app/stackandtile/SATGroup.cpp +++ b/src/servers/app/stackandtile/SATGroup.cpp @@ -883,19 +883,17 @@ SATGroup::RemoveWindow(SATWindow* window, bool stayBelowMouse) if (!fSATWindowList.RemoveItem(window)) return false; - WindowArea* area = window->GetWindowArea(); - if (area) + // We need the area a little bit longer because the area could hold the + // last reference to the group. + BReference area = window->GetWindowArea(); + if (area.Get() != NULL) area->_RemoveWindow(window); - int32 windowCount = CountItems(); - window->RemovedFromGroup(this, stayBelowMouse); - if (windowCount >= 2) + if (CountItems() >= 2) WindowAt(0)->DoGroupLayout(); - // Do nothing after removing the window from the group because this - // could have released the last reference and destroyed ourself. return true; } diff --git a/src/servers/app/stackandtile/SATWindow.cpp b/src/servers/app/stackandtile/SATWindow.cpp index 72bed893cf..b9dbd8a11b 100644 --- a/src/servers/app/stackandtile/SATWindow.cpp +++ b/src/servers/app/stackandtile/SATWindow.cpp @@ -141,7 +141,6 @@ SATWindow::RemovedFromGroup(SATGroup* group, bool stayBelowMouse) if (group->CountItems() == 1) group->WindowAt(0)->_RestoreOriginalSize(false); - fWindowArea = NULL; return true; } @@ -179,6 +178,8 @@ SATWindow::RemovedFromArea(WindowArea* area) fWindow->DetachFromWindowStack(true); for (int i = 0; i < fSATSnappingBehaviourList.CountItems(); i++) fSATSnappingBehaviourList.ItemAt(i)->RemovedFromArea(area); + + fWindowArea = NULL; } diff --git a/src/servers/app/stackandtile/StackAndTile.cpp b/src/servers/app/stackandtile/StackAndTile.cpp index 6bf2963963..ec27493d55 100644 --- a/src/servers/app/stackandtile/StackAndTile.cpp +++ b/src/servers/app/stackandtile/StackAndTile.cpp @@ -342,7 +342,7 @@ StackAndTile::WindowHidden(Window* window, bool fromMinimize) if (group == NULL) return; if (fromMinimize == false && group->CountItems() > 1) - group->RemoveWindow(satWindow); + group->RemoveWindow(satWindow, false); } @@ -412,7 +412,7 @@ StackAndTile::WindowFeelChanged(Window* window, window_feel feel) if (!group) return; if (group->CountItems() > 1) - group->RemoveWindow(satWindow); + group->RemoveWindow(satWindow, false); } @@ -488,7 +488,7 @@ StackAndTile::_StartSAT() if (!group) return; - group->RemoveWindow(fCurrentSATWindow); + group->RemoveWindow(fCurrentSATWindow, false); // Bring window to the front. (in focus follow mouse this is not // automatically the case) _ActivateWindow(fCurrentSATWindow);