From 9f0daa58ea08b4d19d928f2f2e41bb322bdb0dcf Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Fri, 5 Apr 2019 02:51:00 +0200 Subject: [PATCH] Ref T592, made dock widget related slots Qt::QueuedConnection Rational: the widget emits floating but is not yet in full floating state, so with a direct connection we deal a bit too early with the widget. Much more stable (hopefully) using queued connection, then all the handling is done if the window is really a floating window. --- src/blackgui/components/aircraftcomponent.cpp | 2 +- .../components/atcstationcomponent.cpp | 2 +- src/blackgui/components/cockpitcomponent.cpp | 8 +++---- src/blackgui/components/navigatordialog.cpp | 4 ++-- .../components/textmessagecomponent.cpp | 2 +- src/blackgui/components/weathercomponent.cpp | 2 +- src/blackgui/dockwidget.cpp | 24 +++++++++---------- src/blackgui/enablefordockwidgetinfoarea.cpp | 3 +-- src/blackgui/enableforframelesswindow.cpp | 2 +- src/blackgui/infoarea.cpp | 4 ++-- src/swiftguistandard/swiftguistdinit.cpp | 2 +- 11 files changed, 27 insertions(+), 28 deletions(-) diff --git a/src/blackgui/components/aircraftcomponent.cpp b/src/blackgui/components/aircraftcomponent.cpp index d04b918e8..b8eee342a 100644 --- a/src/blackgui/components/aircraftcomponent.cpp +++ b/src/blackgui/components/aircraftcomponent.cpp @@ -87,7 +87,7 @@ namespace BlackGui bool CAircraftComponent::setParentDockWidgetInfoArea(CDockWidgetInfoArea *parentDockableWidget) { CEnableForDockWidgetInfoArea::setParentDockWidgetInfoArea(parentDockableWidget); - const bool c = connect(this->getParentInfoArea(), &CInfoArea::changedInfoAreaTabBarIndex, this, &CAircraftComponent::onInfoAreaTabBarChanged); + const bool c = connect(this->getParentInfoArea(), &CInfoArea::changedInfoAreaTabBarIndex, this, &CAircraftComponent::onInfoAreaTabBarChanged, Qt::QueuedConnection); Q_ASSERT_X(c, Q_FUNC_INFO, "failed connect"); Q_ASSERT_X(parentDockableWidget, Q_FUNC_INFO, "missing parent"); return c && parentDockableWidget; diff --git a/src/blackgui/components/atcstationcomponent.cpp b/src/blackgui/components/atcstationcomponent.cpp index ccdab42cf..d973ad952 100644 --- a/src/blackgui/components/atcstationcomponent.cpp +++ b/src/blackgui/components/atcstationcomponent.cpp @@ -174,7 +174,7 @@ namespace BlackGui bool CAtcStationComponent::setParentDockWidgetInfoArea(CDockWidgetInfoArea *parentDockableWidget) { CEnableForDockWidgetInfoArea::setParentDockWidgetInfoArea(parentDockableWidget); - const bool c = connect(this->getParentInfoArea(), &CInfoArea::changedInfoAreaTabBarIndex, this, &CAtcStationComponent::infoAreaTabBarChanged); + const bool c = connect(this->getParentInfoArea(), &CInfoArea::changedInfoAreaTabBarIndex, this, &CAtcStationComponent::infoAreaTabBarChanged, Qt::QueuedConnection); Q_ASSERT_X(c, Q_FUNC_INFO, "failed connect"); Q_ASSERT_X(parentDockableWidget, Q_FUNC_INFO, "missing parent"); return c && parentDockableWidget; diff --git a/src/blackgui/components/cockpitcomponent.cpp b/src/blackgui/components/cockpitcomponent.cpp index ba2b20d41..d7ddd471c 100644 --- a/src/blackgui/components/cockpitcomponent.cpp +++ b/src/blackgui/components/cockpitcomponent.cpp @@ -27,9 +27,9 @@ namespace BlackGui ui->setupUi(this); m_minHeightInfoArea = ui->comp_CockpitInfoArea->minimumHeight(); - connect(ui->wip_CockpitComPanelShowHideBar, &CShowHideBar::toggleShowHide, this, &CCockpitComponent::onToggleShowHideDetails); - connect(ui->comp_CockpitComComponent, &CCockpitComComponent::requestCom1TextMessage, this, &CCockpitComponent::onRequestTextMessageCom1); - connect(ui->comp_CockpitComComponent, &CCockpitComComponent::requestCom2TextMessage, this, &CCockpitComponent::onRequestTextMessageCom2); + connect(ui->wip_CockpitComPanelShowHideBar, &CShowHideBar::toggleShowHide, this, &CCockpitComponent::onToggleShowHideDetails, Qt::QueuedConnection); + connect(ui->comp_CockpitComComponent, &CCockpitComComponent::requestCom1TextMessage, this, &CCockpitComponent::onRequestTextMessageCom1, Qt::QueuedConnection); + connect(ui->comp_CockpitComComponent, &CCockpitComComponent::requestCom2TextMessage, this, &CCockpitComponent::onRequestTextMessageCom2, Qt::QueuedConnection); } CCockpitComponent::~CCockpitComponent() @@ -41,7 +41,7 @@ namespace BlackGui bool ok = CEnableForDockWidgetInfoArea::setParentDockWidgetInfoArea(parentDockableWidget); if (ok && parentDockableWidget) { - ok = connect(parentDockableWidget, &QDockWidget::topLevelChanged, this, &CCockpitComponent::onToggleFloating); + ok = connect(parentDockableWidget, &QDockWidget::topLevelChanged, this, &CCockpitComponent::onToggleFloating, Qt::QueuedConnection); } return ok; } diff --git a/src/blackgui/components/navigatordialog.cpp b/src/blackgui/components/navigatordialog.cpp index eba4ee5a4..386df9e6c 100644 --- a/src/blackgui/components/navigatordialog.cpp +++ b/src/blackgui/components/navigatordialog.cpp @@ -285,14 +285,14 @@ namespace BlackGui // save a = new QAction(CIcons::save16(), "Save state", this); - c = connect(a, &QAction::triggered, this, &CNavigatorDialog::saveToSettings); + c = connect(a, &QAction::triggered, this, &CNavigatorDialog::saveToSettings, Qt::QueuedConnection); Q_ASSERT(c); this->addAction(a); // close const QIcon i(CIcons::changeIconBackgroundColor(this->style()->standardIcon(QStyle::SP_TitleBarCloseButton), Qt::white, QSize(16, 16))); a = new QAction(i, "Close", this); - c = connect(a, &QAction::triggered, this, &CNavigatorDialog::close); + c = connect(a, &QAction::triggered, this, &CNavigatorDialog::close, Qt::QueuedConnection); Q_ASSERT(c); this->addAction(a); } diff --git a/src/blackgui/components/textmessagecomponent.cpp b/src/blackgui/components/textmessagecomponent.cpp index 123c75e52..7e276cf8e 100644 --- a/src/blackgui/components/textmessagecomponent.cpp +++ b/src/blackgui/components/textmessagecomponent.cpp @@ -119,7 +119,7 @@ namespace BlackGui bool CTextMessageComponent::setParentDockWidgetInfoArea(CDockWidgetInfoArea *parentDockableWidget) { bool c = CEnableForDockWidgetInfoArea::setParentDockWidgetInfoArea(parentDockableWidget); - c = c && connect(this->getDockWidgetInfoArea(), &CDockWidgetInfoArea::widgetTopLevelChanged, this, &CTextMessageComponent::topLevelChanged); + c = c && connect(this->getDockWidgetInfoArea(), &CDockWidgetInfoArea::widgetTopLevelChanged, this, &CTextMessageComponent::topLevelChanged, Qt::QueuedConnection); Q_ASSERT_X(c, Q_FUNC_INFO, "Missing connect"); return c; } diff --git a/src/blackgui/components/weathercomponent.cpp b/src/blackgui/components/weathercomponent.cpp index 007da0dc6..57ab2b7f3 100644 --- a/src/blackgui/components/weathercomponent.cpp +++ b/src/blackgui/components/weathercomponent.cpp @@ -79,7 +79,7 @@ namespace BlackGui bool CWeatherComponent::setParentDockWidgetInfoArea(CDockWidgetInfoArea *parentDockableWidget) { CEnableForDockWidgetInfoArea::setParentDockWidgetInfoArea(parentDockableWidget); - bool c = connect(this->getParentInfoArea(), &CInfoArea::changedInfoAreaTabBarIndex, this, &CWeatherComponent::infoAreaTabBarChanged); + bool c = connect(this->getParentInfoArea(), &CInfoArea::changedInfoAreaTabBarIndex, this, &CWeatherComponent::infoAreaTabBarChanged, Qt::QueuedConnection); Q_ASSERT_X(c, Q_FUNC_INFO, "failed connect"); Q_ASSERT_X(parentDockableWidget, Q_FUNC_INFO, "missing parent"); return c && parentDockableWidget; diff --git a/src/blackgui/dockwidget.cpp b/src/blackgui/dockwidget.cpp index 87e826106..d466c604c 100644 --- a/src/blackgui/dockwidget.cpp +++ b/src/blackgui/dockwidget.cpp @@ -59,15 +59,15 @@ namespace BlackGui m_fontMenu = new CFontMenu(this, Qt::WidgetWithChildrenShortcut); this->setContextMenuPolicy(Qt::CustomContextMenu); - connect(this, &CDockWidget::customContextMenuRequested, this, &CDockWidget::showContextMenu); - connect(m_input, &CMarginsInput::changedMargins, this, &CDockWidget::menuChangeMargins); + connect(this, &CDockWidget::customContextMenuRequested, this, &CDockWidget::showContextMenu, Qt::QueuedConnection); + connect(m_input, &CMarginsInput::changedMargins, this, &CDockWidget::menuChangeMargins, Qt::QueuedConnection); // connect connect(sGui, &CGuiApplication::styleSheetsChanged, this, &CDockWidget::onStyleSheetsChanged, Qt::QueuedConnection); - connect(this, &QDockWidget::topLevelChanged, this, &CDockWidget::onTopLevelChanged); - connect(this, &QDockWidget::visibilityChanged, this, &CDockWidget::onVisibilityChanged); - connect(m_fontMenu, &CFontMenu::fontSizeMinus, this, &CDockWidget::fontSizeMinus); - connect(m_fontMenu, &CFontMenu::fontSizePlus, this, &CDockWidget::fontSizePlus); + connect(this, &QDockWidget::topLevelChanged, this, &CDockWidget::onTopLevelChanged, Qt::QueuedConnection); + connect(this, &QDockWidget::visibilityChanged, this, &CDockWidget::onVisibilityChanged, Qt::QueuedConnection); + connect(m_fontMenu, &CFontMenu::fontSizeMinus, this, &CDockWidget::fontSizeMinus, Qt::QueuedConnection); + connect(m_fontMenu, &CFontMenu::fontSizePlus, this, &CDockWidget::fontSizePlus, Qt::QueuedConnection); } void CDockWidget::setMargins() @@ -363,15 +363,15 @@ namespace BlackGui { const bool frameless = this->isFrameless(); - contextMenu->addAction(CIcons::dockTop16(), "Dock", this, &CDockWidget::toggleFloating); - contextMenu->addAction(CIcons::tableSheet16(), frameless ? "Normal window" : "Frameless", this, &CDockWidget::toggleFrameless); - contextMenu->addAction(CIcons::dockTop16(), "Always on top", this, &CDockWidget::windowAlwaysOnTop); - contextMenu->addAction(CIcons::dockTop16(), "Not on top", this, &CDockWidget::windowNotAlwaysOnTop); - contextMenu->addAction(CIcons::refresh16(), "Redraw", this, qOverload<>(&CDockWidget::update)); + contextMenu->addAction(CIcons::dockTop16(), "Dock", this, &CDockWidget::toggleFloating, Qt::QueuedConnection); + contextMenu->addAction(CIcons::tableSheet16(), frameless ? "Normal window" : "Frameless", this, &CDockWidget::toggleFrameless, Qt::QueuedConnection); + contextMenu->addAction(CIcons::dockTop16(), "Always on top", this, &CDockWidget::windowAlwaysOnTop, Qt::QueuedConnection); + contextMenu->addAction(CIcons::dockTop16(), "Not on top", this, &CDockWidget::windowNotAlwaysOnTop, Qt::QueuedConnection); + contextMenu->addAction(CIcons::refresh16(), "Redraw", this, qOverload<>(&CDockWidget::update), Qt::QueuedConnection); } else { - contextMenu->addAction(CIcons::floatOne16(), "Float", this, &CDockWidget::toggleFloating); + contextMenu->addAction(CIcons::floatOne16(), "Float", this, &CDockWidget::toggleFloating, Qt::QueuedConnection); } // Font actions diff --git a/src/blackgui/enablefordockwidgetinfoarea.cpp b/src/blackgui/enablefordockwidgetinfoarea.cpp index 0c3433901..e1e83566f 100644 --- a/src/blackgui/enablefordockwidgetinfoarea.cpp +++ b/src/blackgui/enablefordockwidgetinfoarea.cpp @@ -62,8 +62,7 @@ namespace BlackGui bool CEnableForDockWidgetInfoArea::isParentDockWidgetFloating() const { - Q_ASSERT(m_parentDockableInfoArea); - if (!m_parentDockableInfoArea) { return false; } + if (!m_parentDockableInfoArea) { return false; } // not floating if not yet initialized return m_parentDockableInfoArea->isFloating(); } diff --git a/src/blackgui/enableforframelesswindow.cpp b/src/blackgui/enableforframelesswindow.cpp index df1a8ea8f..436af5d02 100644 --- a/src/blackgui/enableforframelesswindow.cpp +++ b/src/blackgui/enableforframelesswindow.cpp @@ -263,7 +263,7 @@ namespace BlackGui m_framelessCloseButton = new QPushButton(m_widget); m_framelessCloseButton->setObjectName("pb_FramelessCloseButton"); m_framelessCloseButton->setIcon(CIcons::close16()); - QObject::connect(m_framelessCloseButton, &QPushButton::clicked, m_widget, &QWidget::close); + QObject::connect(m_framelessCloseButton, &QPushButton::clicked, m_widget, &QWidget::close, Qt::QueuedConnection); } QHBoxLayout *menuBarLayout = new QHBoxLayout; diff --git a/src/blackgui/infoarea.cpp b/src/blackgui/infoarea.cpp index f1ab8b3f5..47fd7b889 100644 --- a/src/blackgui/infoarea.cpp +++ b/src/blackgui/infoarea.cpp @@ -256,7 +256,7 @@ namespace BlackGui QAction *action = new QAction(QIcon(pm), wt, parent); action->setData(i); action->setObjectName(this->objectName().append(":getInfoAreaToggleFloatingActions:").append(wt)); - connect(action, &QAction::triggered, this, &CInfoArea::toggleAreaFloatingByAction); + connect(action, &QAction::triggered, this, &CInfoArea::toggleAreaFloatingByAction, Qt::QueuedConnection); actions.append(action); i++; } @@ -643,7 +643,7 @@ namespace BlackGui { for (CDockWidgetInfoArea *dw : as_const(m_dockWidgetInfoAreas)) { - connect(dw, &CDockWidgetInfoArea::widgetTopLevelChanged, this, &CInfoArea::onWidgetTopLevelChanged); + connect(dw, &CDockWidgetInfoArea::widgetTopLevelChanged, this, &CInfoArea::onWidgetTopLevelChanged, Qt::QueuedConnection); } } diff --git a/src/swiftguistandard/swiftguistdinit.cpp b/src/swiftguistandard/swiftguistdinit.cpp index 899506300..02481e97f 100644 --- a/src/swiftguistandard/swiftguistdinit.cpp +++ b/src/swiftguistandard/swiftguistdinit.cpp @@ -273,7 +273,7 @@ void SwiftGuiStd::initGuiSignals() connect(sGui, &CGuiApplication::alwaysOnTop, this, &SwiftGuiStd::onToggledWindowsOnTop); // main info area - connect(ui->comp_MainInfoArea, &CMainInfoAreaComponent::changedWholeInfoAreaFloating, this, &SwiftGuiStd::onChangedMainInfoAreaFloating); + connect(ui->comp_MainInfoArea, &CMainInfoAreaComponent::changedWholeInfoAreaFloating, this, &SwiftGuiStd::onChangedMainInfoAreaFloating, Qt::QueuedConnection); } void SwiftGuiStd::initialContextDataReads()