mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-18 11:42:47 +00:00
Fix crash if we press F5/reload menus when we have a menu open (fix #2496)
This commit is contained in:
parent
6ad0f59e7f
commit
9609d2c827
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2020 Igara Studio S.A.
|
// Copyright (C) 2020-2021 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2017 David Capello
|
// Copyright (C) 2001-2017 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
@ -34,6 +34,9 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onExecute(Context* context) override;
|
void onExecute(Context* context) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void postCancelMenuLoop();
|
||||||
};
|
};
|
||||||
|
|
||||||
RefreshCommand::RefreshCommand()
|
RefreshCommand::RefreshCommand()
|
||||||
@ -42,9 +45,27 @@ RefreshCommand::RefreshCommand()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RefreshCommand::onExecute(Context* context)
|
void RefreshCommand::onExecute(Context* context)
|
||||||
|
{
|
||||||
|
if (!context->isUIAvailable())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Close the current menu loop just in case if there is a menu popup
|
||||||
|
// open, and then enqueue the postReload() function after all menus
|
||||||
|
// are closed.
|
||||||
|
App::instance()->mainWindow()->getMenuBar()->cancelMenuLoop();
|
||||||
|
|
||||||
|
// Now that all menus are going to be closed (the final close
|
||||||
|
// messages are enqueued in the UI message queue), we can queue a
|
||||||
|
// function call that will reload all menus.
|
||||||
|
ui::execute_from_ui_thread(
|
||||||
|
[this]{
|
||||||
|
postCancelMenuLoop();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void RefreshCommand::postCancelMenuLoop()
|
||||||
{
|
{
|
||||||
// Reload menus (mainly to reload the File > Scripts menu)
|
// Reload menus (mainly to reload the File > Scripts menu)
|
||||||
//AppMenus::instance()->reload();
|
|
||||||
App::instance()->mainWindow()->getMenuBar()->reload();
|
App::instance()->mainWindow()->getMenuBar()->reload();
|
||||||
|
|
||||||
// Reload theme
|
// Reload theme
|
||||||
|
Loading…
x
Reference in New Issue
Block a user