mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-26 19:29:16 +00:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user