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.
This commit is contained in:
Klaus Basan
2019-04-05 02:51:00 +02:00
committed by Mat Sutcliffe
parent 423a7dc6f8
commit 9f0daa58ea
11 changed files with 27 additions and 28 deletions

View File

@@ -87,7 +87,7 @@ namespace BlackGui
bool CAircraftComponent::setParentDockWidgetInfoArea(CDockWidgetInfoArea *parentDockableWidget) bool CAircraftComponent::setParentDockWidgetInfoArea(CDockWidgetInfoArea *parentDockableWidget)
{ {
CEnableForDockWidgetInfoArea::setParentDockWidgetInfoArea(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(c, Q_FUNC_INFO, "failed connect");
Q_ASSERT_X(parentDockableWidget, Q_FUNC_INFO, "missing parent"); Q_ASSERT_X(parentDockableWidget, Q_FUNC_INFO, "missing parent");
return c && parentDockableWidget; return c && parentDockableWidget;

View File

@@ -174,7 +174,7 @@ namespace BlackGui
bool CAtcStationComponent::setParentDockWidgetInfoArea(CDockWidgetInfoArea *parentDockableWidget) bool CAtcStationComponent::setParentDockWidgetInfoArea(CDockWidgetInfoArea *parentDockableWidget)
{ {
CEnableForDockWidgetInfoArea::setParentDockWidgetInfoArea(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(c, Q_FUNC_INFO, "failed connect");
Q_ASSERT_X(parentDockableWidget, Q_FUNC_INFO, "missing parent"); Q_ASSERT_X(parentDockableWidget, Q_FUNC_INFO, "missing parent");
return c && parentDockableWidget; return c && parentDockableWidget;

View File

@@ -27,9 +27,9 @@ namespace BlackGui
ui->setupUi(this); ui->setupUi(this);
m_minHeightInfoArea = ui->comp_CockpitInfoArea->minimumHeight(); m_minHeightInfoArea = ui->comp_CockpitInfoArea->minimumHeight();
connect(ui->wip_CockpitComPanelShowHideBar, &CShowHideBar::toggleShowHide, this, &CCockpitComponent::onToggleShowHideDetails); connect(ui->wip_CockpitComPanelShowHideBar, &CShowHideBar::toggleShowHide, this, &CCockpitComponent::onToggleShowHideDetails, Qt::QueuedConnection);
connect(ui->comp_CockpitComComponent, &CCockpitComComponent::requestCom1TextMessage, this, &CCockpitComponent::onRequestTextMessageCom1); connect(ui->comp_CockpitComComponent, &CCockpitComComponent::requestCom1TextMessage, this, &CCockpitComponent::onRequestTextMessageCom1, Qt::QueuedConnection);
connect(ui->comp_CockpitComComponent, &CCockpitComComponent::requestCom2TextMessage, this, &CCockpitComponent::onRequestTextMessageCom2); connect(ui->comp_CockpitComComponent, &CCockpitComComponent::requestCom2TextMessage, this, &CCockpitComponent::onRequestTextMessageCom2, Qt::QueuedConnection);
} }
CCockpitComponent::~CCockpitComponent() CCockpitComponent::~CCockpitComponent()
@@ -41,7 +41,7 @@ namespace BlackGui
bool ok = CEnableForDockWidgetInfoArea::setParentDockWidgetInfoArea(parentDockableWidget); bool ok = CEnableForDockWidgetInfoArea::setParentDockWidgetInfoArea(parentDockableWidget);
if (ok && parentDockableWidget) if (ok && parentDockableWidget)
{ {
ok = connect(parentDockableWidget, &QDockWidget::topLevelChanged, this, &CCockpitComponent::onToggleFloating); ok = connect(parentDockableWidget, &QDockWidget::topLevelChanged, this, &CCockpitComponent::onToggleFloating, Qt::QueuedConnection);
} }
return ok; return ok;
} }

View File

@@ -285,14 +285,14 @@ namespace BlackGui
// save // save
a = new QAction(CIcons::save16(), "Save state", this); 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); Q_ASSERT(c);
this->addAction(a); this->addAction(a);
// close // close
const QIcon i(CIcons::changeIconBackgroundColor(this->style()->standardIcon(QStyle::SP_TitleBarCloseButton), Qt::white, QSize(16, 16))); const QIcon i(CIcons::changeIconBackgroundColor(this->style()->standardIcon(QStyle::SP_TitleBarCloseButton), Qt::white, QSize(16, 16)));
a = new QAction(i, "Close", this); 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); Q_ASSERT(c);
this->addAction(a); this->addAction(a);
} }

View File

@@ -119,7 +119,7 @@ namespace BlackGui
bool CTextMessageComponent::setParentDockWidgetInfoArea(CDockWidgetInfoArea *parentDockableWidget) bool CTextMessageComponent::setParentDockWidgetInfoArea(CDockWidgetInfoArea *parentDockableWidget)
{ {
bool c = CEnableForDockWidgetInfoArea::setParentDockWidgetInfoArea(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"); Q_ASSERT_X(c, Q_FUNC_INFO, "Missing connect");
return c; return c;
} }

View File

@@ -79,7 +79,7 @@ namespace BlackGui
bool CWeatherComponent::setParentDockWidgetInfoArea(CDockWidgetInfoArea *parentDockableWidget) bool CWeatherComponent::setParentDockWidgetInfoArea(CDockWidgetInfoArea *parentDockableWidget)
{ {
CEnableForDockWidgetInfoArea::setParentDockWidgetInfoArea(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(c, Q_FUNC_INFO, "failed connect");
Q_ASSERT_X(parentDockableWidget, Q_FUNC_INFO, "missing parent"); Q_ASSERT_X(parentDockableWidget, Q_FUNC_INFO, "missing parent");
return c && parentDockableWidget; return c && parentDockableWidget;

View File

@@ -59,15 +59,15 @@ namespace BlackGui
m_fontMenu = new CFontMenu(this, Qt::WidgetWithChildrenShortcut); m_fontMenu = new CFontMenu(this, Qt::WidgetWithChildrenShortcut);
this->setContextMenuPolicy(Qt::CustomContextMenu); this->setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, &CDockWidget::customContextMenuRequested, this, &CDockWidget::showContextMenu); connect(this, &CDockWidget::customContextMenuRequested, this, &CDockWidget::showContextMenu, Qt::QueuedConnection);
connect(m_input, &CMarginsInput::changedMargins, this, &CDockWidget::menuChangeMargins); connect(m_input, &CMarginsInput::changedMargins, this, &CDockWidget::menuChangeMargins, Qt::QueuedConnection);
// connect // connect
connect(sGui, &CGuiApplication::styleSheetsChanged, this, &CDockWidget::onStyleSheetsChanged, Qt::QueuedConnection); connect(sGui, &CGuiApplication::styleSheetsChanged, this, &CDockWidget::onStyleSheetsChanged, Qt::QueuedConnection);
connect(this, &QDockWidget::topLevelChanged, this, &CDockWidget::onTopLevelChanged); connect(this, &QDockWidget::topLevelChanged, this, &CDockWidget::onTopLevelChanged, Qt::QueuedConnection);
connect(this, &QDockWidget::visibilityChanged, this, &CDockWidget::onVisibilityChanged); connect(this, &QDockWidget::visibilityChanged, this, &CDockWidget::onVisibilityChanged, Qt::QueuedConnection);
connect(m_fontMenu, &CFontMenu::fontSizeMinus, this, &CDockWidget::fontSizeMinus); connect(m_fontMenu, &CFontMenu::fontSizeMinus, this, &CDockWidget::fontSizeMinus, Qt::QueuedConnection);
connect(m_fontMenu, &CFontMenu::fontSizePlus, this, &CDockWidget::fontSizePlus); connect(m_fontMenu, &CFontMenu::fontSizePlus, this, &CDockWidget::fontSizePlus, Qt::QueuedConnection);
} }
void CDockWidget::setMargins() void CDockWidget::setMargins()
@@ -363,15 +363,15 @@ namespace BlackGui
{ {
const bool frameless = this->isFrameless(); const bool frameless = this->isFrameless();
contextMenu->addAction(CIcons::dockTop16(), "Dock", this, &CDockWidget::toggleFloating); contextMenu->addAction(CIcons::dockTop16(), "Dock", this, &CDockWidget::toggleFloating, Qt::QueuedConnection);
contextMenu->addAction(CIcons::tableSheet16(), frameless ? "Normal window" : "Frameless", this, &CDockWidget::toggleFrameless); contextMenu->addAction(CIcons::tableSheet16(), frameless ? "Normal window" : "Frameless", this, &CDockWidget::toggleFrameless, Qt::QueuedConnection);
contextMenu->addAction(CIcons::dockTop16(), "Always on top", this, &CDockWidget::windowAlwaysOnTop); contextMenu->addAction(CIcons::dockTop16(), "Always on top", this, &CDockWidget::windowAlwaysOnTop, Qt::QueuedConnection);
contextMenu->addAction(CIcons::dockTop16(), "Not on top", this, &CDockWidget::windowNotAlwaysOnTop); contextMenu->addAction(CIcons::dockTop16(), "Not on top", this, &CDockWidget::windowNotAlwaysOnTop, Qt::QueuedConnection);
contextMenu->addAction(CIcons::refresh16(), "Redraw", this, qOverload<>(&CDockWidget::update)); contextMenu->addAction(CIcons::refresh16(), "Redraw", this, qOverload<>(&CDockWidget::update), Qt::QueuedConnection);
} }
else else
{ {
contextMenu->addAction(CIcons::floatOne16(), "Float", this, &CDockWidget::toggleFloating); contextMenu->addAction(CIcons::floatOne16(), "Float", this, &CDockWidget::toggleFloating, Qt::QueuedConnection);
} }
// Font actions // Font actions

View File

@@ -62,8 +62,7 @@ namespace BlackGui
bool CEnableForDockWidgetInfoArea::isParentDockWidgetFloating() const bool CEnableForDockWidgetInfoArea::isParentDockWidgetFloating() const
{ {
Q_ASSERT(m_parentDockableInfoArea); if (!m_parentDockableInfoArea) { return false; } // not floating if not yet initialized
if (!m_parentDockableInfoArea) { return false; }
return m_parentDockableInfoArea->isFloating(); return m_parentDockableInfoArea->isFloating();
} }

View File

@@ -263,7 +263,7 @@ namespace BlackGui
m_framelessCloseButton = new QPushButton(m_widget); m_framelessCloseButton = new QPushButton(m_widget);
m_framelessCloseButton->setObjectName("pb_FramelessCloseButton"); m_framelessCloseButton->setObjectName("pb_FramelessCloseButton");
m_framelessCloseButton->setIcon(CIcons::close16()); 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; QHBoxLayout *menuBarLayout = new QHBoxLayout;

View File

@@ -256,7 +256,7 @@ namespace BlackGui
QAction *action = new QAction(QIcon(pm), wt, parent); QAction *action = new QAction(QIcon(pm), wt, parent);
action->setData(i); action->setData(i);
action->setObjectName(this->objectName().append(":getInfoAreaToggleFloatingActions:").append(wt)); 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); actions.append(action);
i++; i++;
} }
@@ -643,7 +643,7 @@ namespace BlackGui
{ {
for (CDockWidgetInfoArea *dw : as_const(m_dockWidgetInfoAreas)) for (CDockWidgetInfoArea *dw : as_const(m_dockWidgetInfoAreas))
{ {
connect(dw, &CDockWidgetInfoArea::widgetTopLevelChanged, this, &CInfoArea::onWidgetTopLevelChanged); connect(dw, &CDockWidgetInfoArea::widgetTopLevelChanged, this, &CInfoArea::onWidgetTopLevelChanged, Qt::QueuedConnection);
} }
} }

View File

@@ -273,7 +273,7 @@ void SwiftGuiStd::initGuiSignals()
connect(sGui, &CGuiApplication::alwaysOnTop, this, &SwiftGuiStd::onToggledWindowsOnTop); connect(sGui, &CGuiApplication::alwaysOnTop, this, &SwiftGuiStd::onToggledWindowsOnTop);
// main info area // 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() void SwiftGuiStd::initialContextDataReads()