ladybird/Applications/FontEditor
Ben Wiederhake c9bafa9467 FontEditor: Cannot take reference to local lambda
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.
2020-08-30 10:31:04 +02:00
..
.gitignore FontEditor: Initial port to using a VisualBuilder generated UI. 2019-07-11 20:19:26 +02:00
CMakeLists.txt Build: Switch to CMake :^) 2020-05-14 20:15:18 +02:00
FontEditor.cpp FontEditor: Cannot take reference to local lambda 2020-08-30 10:31:04 +02:00
FontEditor.h FontEditor: Add a "Save as..." menu item 2020-07-11 11:34:38 +02:00
GlyphEditorWidget.cpp FontEditor: Enforce boundaries of GlyphEditorWidget 2020-08-30 10:31:04 +02:00
GlyphEditorWidget.h Meta: Add a script check the presence of "#pragma once" in header files 2020-05-29 07:59:45 +02:00
GlyphMapWidget.cpp LibGfx: Rename Rect,Point,Size => IntRect,IntPoint,IntSize 2020-06-10 10:59:04 +02:00
GlyphMapWidget.h LibGfx: Rename Rect,Point,Size => IntRect,IntPoint,IntSize 2020-06-10 10:59:04 +02:00
main.cpp Applications: Stop setting initial window location 2020-08-01 08:06:48 +02:00