mirror of
https://github.com/RGBCube/serenity
synced 2025-10-13 19:42:08 +00:00
![]() Under the hood, a lambda is just a struct full of pointers/references/copies and whatever else the compiler deems necessary. In the case of 'update_demo', the struct lives on the stack frame of FontEditorWidget::FontEditorWidget(). Hence it is still alive when it's called during the constructor. However, when 'fixed_width_checkbox.on_checked' fires, that stack frame is no longer alive, and thus the *reference* to the (struct of) the lambda is invalid\! This meant that 'update_demo' silently read invalid data, tried to call '.update()' on some innocent arbitrary memory address, and it crashed somewhere unrelated. Passing 'update_demo' by value (like with all the other event handlers) fixes this issue. Note that this solution only works because 'update_demo' itself has no state; otherwise the various copies of 'update_demo' might notice that they are, in fact, independent copies of the original lambda. But that doesn't matter here. |
||
---|---|---|
.. | ||
About | ||
Browser | ||
Calculator | ||
Calendar | ||
Debugger | ||
DisplaySettings | ||
FileManager | ||
FontEditor | ||
Help | ||
HexEditor | ||
IRCClient | ||
KeyboardMapper | ||
KeyboardSettings | ||
Piano | ||
PixelPaint | ||
QuickShow | ||
SoundPlayer | ||
Spreadsheet | ||
SystemMonitor | ||
Terminal | ||
TextEditor | ||
ThemeEditor | ||
Welcome | ||
CMakeLists.txt |