app_server: Reset current view also when deleting a parent view.

The check that was in place only ensured that the current view was reset
if the current view itself got deleted. Since deleting views works by
token it is possible that a view other than the current view gets
deleted. When a parent of the current view was deleted, which also
deletes all its children, the current view pointer was not reset and
the stale pointer would still be accessed.
This commit is contained in:
Michael Lotz
2015-04-04 22:58:45 +02:00
parent 35965e5867
commit 442e7caa49
2 changed files with 10 additions and 1 deletions
+3 -1
View File
@@ -1265,8 +1265,10 @@ fDesktop->UnlockSingleWindow();
EventTarget(), token);
fDesktop->LockSingleWindow();
}
if (fCurrentView == view)
if (fCurrentView == view || fCurrentView->HasParent(view))
_SetCurrentView(parent);
delete view;
} // else we don't delete the root view
}
+7
View File
@@ -83,6 +83,13 @@ public:
void AddChild(View* view);
bool RemoveChild(View* view);
inline bool HasParent(View* candidate) const
{
return fParent == candidate
|| (fParent != NULL
&& fParent->HasParent(candidate));
}
inline View* Parent() const
{ return fParent; }