mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:08:11 +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:
parent
dd2e8b7dd0
commit
b00a347ac5
1 changed files with 3 additions and 0 deletions
|
@ -108,6 +108,9 @@ void Button::click(unsigned modifiers)
|
||||||
{
|
{
|
||||||
if (!is_enabled())
|
if (!is_enabled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
NonnullRefPtr protector = *this;
|
||||||
|
|
||||||
if (is_checkable()) {
|
if (is_checkable()) {
|
||||||
if (is_checked() && !is_uncheckable())
|
if (is_checked() && !is_uncheckable())
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue