mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-09 04:15:52 +00:00
Nitpicker: avoid potential dangling pointer
This commit is contained in:
parent
7b11075264
commit
2dba94eba9
@ -305,15 +305,23 @@ View *View_stack::find_view(Point p)
|
||||
|
||||
void View_stack::remove_view(View *view)
|
||||
{
|
||||
/* reset focused view if necessary */
|
||||
_mode->forget(view);
|
||||
|
||||
/* remember geometry of view to remove */
|
||||
Rect rect = _outline(view);
|
||||
|
||||
/* exclude view from view stack */
|
||||
_views.remove(view);
|
||||
|
||||
/*
|
||||
* Reset focused and pointed-at view if necessary
|
||||
*
|
||||
* Thus must be done after calling '_views.remove' because the new focused
|
||||
* pointer is determined by traversing the view stack. If the to-be-removed
|
||||
* view would still be there, we would re-assign the old pointed-to view as
|
||||
* the current one, resulting in a dangling pointer right after the view
|
||||
* gets destructed by the caller of 'removed_view'.
|
||||
*/
|
||||
_mode->forget(view);
|
||||
|
||||
/* redraw area where the view was visible */
|
||||
draw_rec(_first_view(), 0, 0, rect);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user