mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
c9bafa9467
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. |
||
---|---|---|
.. | ||
.gitignore | ||
CMakeLists.txt | ||
FontEditor.cpp | ||
FontEditor.h | ||
GlyphEditorWidget.cpp | ||
GlyphEditorWidget.h | ||
GlyphMapWidget.cpp | ||
GlyphMapWidget.h | ||
main.cpp |