mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:17:44 +00:00
LibGUI: GWindow's focused widget should be a WeakPtr.
This fixes some very obvious use-after-free accesses.
This commit is contained in:
parent
9e6b0ccc0e
commit
cc9cefbd5f
2 changed files with 2 additions and 2 deletions
|
@ -337,7 +337,7 @@ void GWindow::set_focused_widget(GWidget* widget)
|
||||||
GEventLoop::current().post_event(*m_focused_widget, make<GEvent>(GEvent::FocusOut));
|
GEventLoop::current().post_event(*m_focused_widget, make<GEvent>(GEvent::FocusOut));
|
||||||
m_focused_widget->update();
|
m_focused_widget->update();
|
||||||
}
|
}
|
||||||
m_focused_widget = widget;
|
m_focused_widget = widget ? widget->make_weak_ptr() : nullptr;
|
||||||
if (m_focused_widget) {
|
if (m_focused_widget) {
|
||||||
GEventLoop::current().post_event(*m_focused_widget, make<GEvent>(GEvent::FocusIn));
|
GEventLoop::current().post_event(*m_focused_widget, make<GEvent>(GEvent::FocusIn));
|
||||||
m_focused_widget->update();
|
m_focused_widget->update();
|
||||||
|
|
|
@ -120,7 +120,7 @@ private:
|
||||||
int m_window_id { 0 };
|
int m_window_id { 0 };
|
||||||
float m_opacity_when_windowless { 1.0f };
|
float m_opacity_when_windowless { 1.0f };
|
||||||
GWidget* m_main_widget { nullptr };
|
GWidget* m_main_widget { nullptr };
|
||||||
GWidget* m_focused_widget { nullptr };
|
WeakPtr<GWidget> m_focused_widget;
|
||||||
WeakPtr<GWidget> m_global_cursor_tracking_widget;
|
WeakPtr<GWidget> m_global_cursor_tracking_widget;
|
||||||
WeakPtr<GWidget> m_automatic_cursor_tracking_widget;
|
WeakPtr<GWidget> m_automatic_cursor_tracking_widget;
|
||||||
WeakPtr<GWidget> m_hovered_widget;
|
WeakPtr<GWidget> m_hovered_widget;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue