Skip to content

Commit 31a2ac9

Browse files
ClysmiCawesomekling
authored andcommitted
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.
1 parent 9246ad9 commit 31a2ac9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Userland/Libraries/LibGUI/SpinBox.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ SpinBox::SpinBox()
1818
set_fixed_height(22);
1919
m_editor = add<TextBox>();
2020
m_editor->set_text("0");
21-
m_editor->on_change = [this] {
21+
m_editor->on_change = [this, weak_this = make_weak_ptr()] {
22+
if (!weak_this)
23+
return;
24+
2225
auto value = m_editor->text().to_uint();
2326
if (value.has_value())
2427
set_value(value.value());

0 commit comments

Comments
 (0)