Skip to content

Commit

Permalink
Gui: fix crash on contextual pie menu switching workbench
Browse files Browse the repository at this point in the history
Fixes #978
  • Loading branch information
realthunder committed May 28, 2024
1 parent 5b55b77 commit 6891615
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Gui/Action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2671,7 +2671,7 @@ class StdCmdToolbarSubMenu : public Gui::Command
// --------------------------------------------------------------------

ToolbarMenuAction::ToolbarMenuAction ( Command* pcCmd, QObject * parent )
: Action(pcCmd, parent), _menu(0)
: Action(pcCmd, parent), _menu(nullptr)
, _pimpl(new Private(this, "User parameter:BaseApp/Workbench/Global/Toolbar"))
{
_pimpl->hShortcut = WindowParameter::getDefaultParameter()->GetGroup("Shortcut");
Expand Down Expand Up @@ -2800,8 +2800,16 @@ void ToolbarMenuAction::update()

void ToolbarMenuAction::popup(const QPoint &pt)
{
_menu->setActiveAction(nullptr);
PieMenu::exec(_menu, pt, command()->getName());
_menu->setActiveAction(0);

// WARNING! In some case, this ToolbarMenuAction instance may have been
// destroyed after returning from PieMenu::exec(). E.g. when the toolbar
// menu is a PartDesign context menu/command, and the action triggers
// switching to Sketcher workbench, causing all PartDesign context commands
// being destroyed. So, must not access any member here.
//
// _menu->setActiveAction(nullptr);
}

////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 6891615

Please sign in to comment.