mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-21 10:19:03 +03:00
LibGUI: Fix crash in GML Playground auto-completing SpinBox props
Crash was caused by deferred invocation of a lambda on the SpinBox's TextEditor widget's on_change. The lambda referenced the SpinBox ptr, but in GML Playground the SpinBox was free'd before the deferred lambda could run, causing a use-after-free error. Fixed by using a weak ptr to detect if the SpinBox was free'd.
This commit is contained in:
parent
9246ad96b3
commit
31a2ac94c7
Notes:
sideshowbarker
2024-07-17 21:16:31 +09:00
Author: https://github.com/ClysmiC 🔰 Commit: https://github.com/SerenityOS/serenity/commit/31a2ac94c7 Pull-request: https://github.com/SerenityOS/serenity/pull/12942 Issue: https://github.com/SerenityOS/serenity/issues/12939
@ -18,7 +18,10 @@ SpinBox::SpinBox()
|
||||
set_fixed_height(22);
|
||||
m_editor = add<TextBox>();
|
||||
m_editor->set_text("0");
|
||||
m_editor->on_change = [this] {
|
||||
m_editor->on_change = [this, weak_this = make_weak_ptr()] {
|
||||
if (!weak_this)
|
||||
return;
|
||||
|
||||
auto value = m_editor->text().to_uint();
|
||||
if (value.has_value())
|
||||
set_value(value.value());
|
||||
|
Loading…
Reference in New Issue
Block a user