mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:57:43 +00:00
LibGUI: Put a governor on Action activation
Many actions affect Window modality, so let's put a temporary change governor on activation to stop race conditions. Fixes being able to spam open/close shortcuts and spawn multiple FilePickers, among other things.
This commit is contained in:
parent
7323a54e59
commit
c87c4f6d94
2 changed files with 9 additions and 1 deletions
|
@ -4,6 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/TemporaryChange.h>
|
||||
#include <LibGUI/Action.h>
|
||||
#include <LibGUI/ActionGroup.h>
|
||||
#include <LibGUI/Application.h>
|
||||
|
@ -132,7 +133,7 @@ Action::~Action()
|
|||
|
||||
void Action::process_event(Window& window, Event& event)
|
||||
{
|
||||
if (is_enabled() && is_visible()) {
|
||||
if (is_enabled() && is_visible() && !is_activating()) {
|
||||
flash_menubar_menu(window);
|
||||
activate();
|
||||
event.accept();
|
||||
|
@ -148,6 +149,10 @@ void Action::process_event(Window& window, Event& event)
|
|||
|
||||
void Action::activate(Core::Object* activator)
|
||||
{
|
||||
if (is_activating())
|
||||
return;
|
||||
TemporaryChange change { m_activating, true };
|
||||
|
||||
if (!on_activation)
|
||||
return;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue