When an app is going down and the windows are destroyed, all views are detached.

On detaching the views remove themselves from the app local token space. Since
the ServerApp only waits for all ServerWindows to be removed from the window
list and not for their actual destruction, it can happen that the ServerApp is
deleted before the window destruction and hence the view detaching has finished.
The views would then access a stale ServerApp pointer and try to remove their
token from the deleted token space. To avoid that we set the ServerApp pointer
to NULL when the window is removed from the app (as after that the app can be
gone any time) and check for that case when detaching.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32927 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz
2009-09-03 22:56:30 +00:00
parent 86e78dfaad
commit edb6254810
2 changed files with 4 additions and 2 deletions
+3 -1
View File
@@ -197,8 +197,10 @@ ServerWindow::~ServerWindow()
fDesktop->RemoveWindow(fWindow);
}
if (App() != NULL)
if (App() != NULL) {
App()->RemoveWindow(this);
fServerApp = NULL;
}
delete fWindow;
+1 -1
View File
@@ -206,7 +206,7 @@ void
View::DetachedFromWindow()
{
// remove view from local token space
if (fWindow != NULL)
if (fWindow != NULL && fWindow->ServerWindow()->App() != NULL)
fWindow->ServerWindow()->App()->ViewTokens().RemoveToken(fToken);
fWindow = NULL;