Fix toggleAction() emitting spurious toggle events

When showing a dockwidget it's inserted into a tab widget, which
will generate a hide event, which will toggle the action to off
even though the dock widget is opened for our purposes
This commit is contained in:
Sergio Martins
2020-02-05 13:06:53 +00:00
parent 1cac350547
commit 3771aa7a40

View File

@@ -62,8 +62,11 @@ public:
q->connect(q, &DockWidgetBase::hidden, q, [this] { onDockWidgetHidden(); } );
q->connect(toggleAction, &QAction::toggled, q, [this] (bool enabled) {
if (!m_updatingToggleAction) // guard against recursiveness
if (!m_updatingToggleAction) { // guard against recursiveness
toggleAction->blockSignals(true); // and don't emit spurious toggle. Like when a dock widget is inserted into a tab widget it might get hide events, ignore those. The Dock Widget is open.
toggle(enabled);
toggleAction->blockSignals(false);
}
});
toggleAction->setCheckable(true);