mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-21 02:01:38 +00:00
nitpicker: Fix implementation of Mode interface
The generalization of nitpicker's graphic backend changed the interface of 'Mode::forget', which is a (non-pure) virtual function implemented by 'User_state::forget'. Unfortunately, the signature change was not applied to 'User_state::forget' so that the actual implementation was no longer called. This inconsistency remained unnoticed because there is a default implementation of the virtual function. The effect of the omission of the 'User_state::forget' call was a dangling pointer ('User_state::_pointed_view'). Lesson learned: Always annotate functions with the C++11 'override' when implementing virtual functions.
This commit is contained in:
parent
2262eb8347
commit
2f3b67c9e0
@ -15,6 +15,7 @@
|
||||
#define _MODE_H_
|
||||
|
||||
class View;
|
||||
class Canvas_base;
|
||||
|
||||
class Mode
|
||||
{
|
||||
@ -53,7 +54,7 @@ class Mode
|
||||
/**
|
||||
* Discard all references to specified view
|
||||
*/
|
||||
virtual void forget(View const &v) {
|
||||
virtual void forget(Canvas_base &, View const &v) {
|
||||
if (&v == _focused_view) _focused_view = 0; }
|
||||
};
|
||||
|
||||
|
@ -281,7 +281,7 @@ void User_state::handle_event(Input::Event ev, Canvas_base &canvas)
|
||||
void User_state::forget(Canvas_base &canvas, View const &view)
|
||||
{
|
||||
if (focused_view() == &view) {
|
||||
Mode::forget(view);
|
||||
Mode::forget(canvas, view);
|
||||
_menubar.state(Menubar_state(*this, "", "", BLACK));
|
||||
update_all_views(canvas);
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ class User_state : public Mode, public View_stack
|
||||
/**
|
||||
* Mode interface
|
||||
*/
|
||||
void forget(Canvas_base &, View const &);
|
||||
void forget(Canvas_base &, View const &) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -315,7 +315,7 @@ void View_stack::remove_view(Canvas_base &canvas, View const &view, bool redraw)
|
||||
* the current one, resulting in a dangling pointer right after the view
|
||||
* gets destructed by the caller of 'removed_view'.
|
||||
*/
|
||||
_mode.forget(view);
|
||||
_mode.forget(canvas, view);
|
||||
|
||||
/* redraw area where the view was visible */
|
||||
if (redraw)
|
||||
|
Loading…
x
Reference in New Issue
Block a user