LibGUI: Protect GUI::Button across firing the on_click hook

If a hook triggers the deletion of the GUI::Button, we would be unable
to proceed in a well-defined manner here, so let's protect ourselves.

This probably needs to be done in a whole lot of places, since GUI
widgets are just ref-counted Core::Objects and running arbitrary code
can mean that they get deleted.
This commit is contained in:
Andreas Kling
2020-12-14 19:37:55 +01:00
parent dd2e8b7dd0
commit b00a347ac5

View File

@@ -108,6 +108,9 @@ void Button::click(unsigned modifiers)
{
if (!is_enabled())
return;
NonnullRefPtr protector = *this;
if (is_checkable()) {
if (is_checked() && !is_uncheckable())
return;