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:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user