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)
{
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;

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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

View File

@@ -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();
}

View File

@@ -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;

View File

@@ -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);
}
}

View File

@@ -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()