Use a RAII class to emit floatingChanging()
Otherwise during reparenting the signal can be emitted by mistake. Now we only check at the end if we need to emit it.
This commit is contained in:
@@ -680,6 +680,9 @@ void DockWidget::Private::updateToggleAction()
|
||||
|
||||
void DockWidget::Private::updateFloatAction()
|
||||
{
|
||||
if (m_willUpdateActions)
|
||||
return;
|
||||
|
||||
QScopedValueRollback<bool> recursionGuard(m_updatingFloatAction, true); // Guard against recursiveness
|
||||
|
||||
if (q->isFloating()) {
|
||||
|
||||
@@ -36,6 +36,27 @@ class SideBar;
|
||||
class DOCKS_EXPORT_FOR_UNIT_TESTS DockWidget::Private : public QObject /// clazy:exclude=missing-qobject-macro
|
||||
{
|
||||
public:
|
||||
/// RAII class to help updating actions exactly once, otherwise they can be triggered in the middle
|
||||
/// of operations during reparenting
|
||||
struct UpdateActions
|
||||
{
|
||||
explicit UpdateActions(Controllers::DockWidget *dw)
|
||||
: dw(dw)
|
||||
{
|
||||
dw->d->m_willUpdateActions = true;
|
||||
}
|
||||
|
||||
~UpdateActions()
|
||||
{
|
||||
dw->d->m_willUpdateActions = false;
|
||||
dw->d->updateFloatAction();
|
||||
}
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(UpdateActions)
|
||||
Controllers::DockWidget *const dw;
|
||||
};
|
||||
|
||||
Private(const QString &dockName, DockWidget::Options options_,
|
||||
LayoutSaverOptions layoutSaverOptions_, DockWidget *qq);
|
||||
|
||||
@@ -175,7 +196,9 @@ public:
|
||||
bool m_isMovingToSideBar = false;
|
||||
QSize m_lastOverlayedSize = QSize(0, 0);
|
||||
int m_userType = 0;
|
||||
bool m_willUpdateActions = false;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -169,6 +169,8 @@ void DropArea::addDockWidget(Controllers::DockWidget *dw, Location location,
|
||||
if (!validateAffinity(dw))
|
||||
return;
|
||||
|
||||
Controllers::DockWidget::Private::UpdateActions actionsUpdater(dw);
|
||||
|
||||
Controllers::Frame *frame = nullptr;
|
||||
Controllers::Frame *relativeToFrame = relativeTo ? relativeTo->d->frame() : nullptr;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user