From edb6254810123b41166fb49c1a7413b77205694b Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Thu, 3 Sep 2009 22:56:30 +0000 Subject: [PATCH] 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 --- src/servers/app/ServerWindow.cpp | 4 +++- src/servers/app/View.cpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp index e6e8a139d8..dc8a2f5500 100644 --- a/src/servers/app/ServerWindow.cpp +++ b/src/servers/app/ServerWindow.cpp @@ -197,8 +197,10 @@ ServerWindow::~ServerWindow() fDesktop->RemoveWindow(fWindow); } - if (App() != NULL) + if (App() != NULL) { App()->RemoveWindow(this); + fServerApp = NULL; + } delete fWindow; diff --git a/src/servers/app/View.cpp b/src/servers/app/View.cpp index bb4bb92a7b..b496683d16 100644 --- a/src/servers/app/View.cpp +++ b/src/servers/app/View.cpp @@ -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;