From 3588c5a60184aaf55e4488ef7e1b49fe1be384b2 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Thu, 17 Mar 2016 20:14:55 +0000 Subject: [PATCH] refs #599, fixes and improvements (assert/checks) for https://dev.vatsim-germany.org/issues/599#note-5 --- .../dbdistributorselectorcomponent.cpp | 11 +++++++--- .../infobarwebreadersstatuscomponent.cpp | 9 ++++++-- .../components/textmessagecomponent.cpp | 21 +++++++++++++------ .../components/textmessagecomponent.h | 3 +++ 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/src/blackgui/components/dbdistributorselectorcomponent.cpp b/src/blackgui/components/dbdistributorselectorcomponent.cpp index 20f398e9c..316b4e25d 100644 --- a/src/blackgui/components/dbdistributorselectorcomponent.cpp +++ b/src/blackgui/components/dbdistributorselectorcomponent.cpp @@ -27,19 +27,24 @@ namespace BlackGui QFrame(parent), ui(new Ui::CDbDistributorSelectorComponent) { + Q_ASSERT_X(sGui, Q_FUNC_INFO, "Missing sGui"); ui->setupUi(this); this->setAcceptDrops(true); this->setAcceptedMetaTypeIds({qMetaTypeId(), qMetaTypeId()}); this->ui->le_Distributor->setValidator(new CUpperCaseValidator(this)); - connect(ui->le_Distributor, &QLineEdit::returnPressed, this, &CDbDistributorSelectorComponent::ps_dataChanged); - connect(sApp->getWebDataServices(), &CWebDataServices::dataRead, this, &CDbDistributorSelectorComponent::ps_distributorsRead); + bool c = connect(ui->le_Distributor, &QLineEdit::returnPressed, this, &CDbDistributorSelectorComponent::ps_dataChanged); + Q_ASSERT_X(c, Q_FUNC_INFO, "Missing connect"); + c = connect(sApp->getWebDataServices(), &CWebDataServices::dataRead, this, &CDbDistributorSelectorComponent::ps_distributorsRead); + Q_ASSERT_X(c, Q_FUNC_INFO, "Missing connect"); + Q_UNUSED(c); + this->ps_distributorsRead(CEntityFlags::DistributorEntity, CEntityFlags::ReadFinished, sApp->getWebDataServices()->getDistributorsCount()); } CDbDistributorSelectorComponent::~CDbDistributorSelectorComponent() { - // + // void } void CDbDistributorSelectorComponent::setDistributor(const CDistributor &distributor) diff --git a/src/blackgui/components/infobarwebreadersstatuscomponent.cpp b/src/blackgui/components/infobarwebreadersstatuscomponent.cpp index 8c15d761c..034044d05 100644 --- a/src/blackgui/components/infobarwebreadersstatuscomponent.cpp +++ b/src/blackgui/components/infobarwebreadersstatuscomponent.cpp @@ -26,13 +26,18 @@ namespace BlackGui CInfoBarWebReadersStatusComponent::CInfoBarWebReadersStatusComponent(QWidget *parent) : QFrame(parent), ui(new Ui::CInfoBarWebReadersStatusComponent) { + Q_ASSERT_X(sGui, Q_FUNC_INFO, "No sGui"); + Q_ASSERT_X(sGui->hasWebDataServices(), Q_FUNC_INFO, "No web data services"); ui->setupUi(this); this->initLeds(); - connect(&m_timer, &QTimer::timeout, this, &CInfoBarWebReadersStatusComponent::ps_checkServerAndData); + bool c = connect(&m_timer, &QTimer::timeout, this, &CInfoBarWebReadersStatusComponent::ps_checkServerAndData); + Q_ASSERT_X(c, Q_FUNC_INFO, "Failed connect"); m_timer.setInterval(30 * 1000); m_timer.start(); m_timer.setObjectName("CInfoBarWebReadersStatusComponent::CheckSwiftDbTimer"); - connect(sGui->getWebDataServices(), &CWebDataServices::dataRead, this, &CInfoBarWebReadersStatusComponent::ps_dataRead); + c = connect(sGui->getWebDataServices(), &CWebDataServices::dataRead, this, &CInfoBarWebReadersStatusComponent::ps_dataRead); + Q_ASSERT_X(c, Q_FUNC_INFO, "Failed connect"); + Q_UNUSED(c); } CInfoBarWebReadersStatusComponent::~CInfoBarWebReadersStatusComponent() diff --git a/src/blackgui/components/textmessagecomponent.cpp b/src/blackgui/components/textmessagecomponent.cpp index 34c033199..e27571314 100644 --- a/src/blackgui/components/textmessagecomponent.cpp +++ b/src/blackgui/components/textmessagecomponent.cpp @@ -34,7 +34,6 @@ namespace BlackGui { namespace Components { - CTextMessageComponent::CTextMessageComponent(QWidget *parent) : QFrame(parent), ui(new Ui::CTextMessageComponent) @@ -42,18 +41,28 @@ namespace BlackGui ui->setupUi(this); this->ui->le_textMessages->setVisible(false); - connect(this->ui->le_textMessages, &QLineEdit::returnPressed, this, &CTextMessageComponent::ps_textMessageEntered); - this->ui->tvp_TextMessagesAll->setResizeMode(CTextMessageView::ResizingAuto); - connect(sGui->getIContextOwnAircraft(), &IContextOwnAircraft::changedAircraftCockpit, this, &CTextMessageComponent::ps_onChangedAircraftCockpit); - connect(this->getDockWidgetInfoArea(), &CDockWidgetInfoArea::widgetTopLevelChanged, this, &CTextMessageComponent::ps_topLevelChanged); - connect(this, &CTextMessageComponent::commandEntered, sApp->getCoreFacade(), &CCoreFacade::parseCommandLine); + bool c = connect(this->ui->le_textMessages, &QLineEdit::returnPressed, this, &CTextMessageComponent::ps_textMessageEntered); + Q_ASSERT_X(c, Q_FUNC_INFO, "Missing connect"); + c = connect(sGui->getIContextOwnAircraft(), &IContextOwnAircraft::changedAircraftCockpit, this, &CTextMessageComponent::ps_onChangedAircraftCockpit); + Q_ASSERT_X(c, Q_FUNC_INFO, "Missing connect"); + c = connect(this, &CTextMessageComponent::commandEntered, sApp->getCoreFacade(), &CCoreFacade::parseCommandLine); + Q_ASSERT_X(c, Q_FUNC_INFO, "Missing connect"); + Q_UNUSED(c); } CTextMessageComponent::~CTextMessageComponent() { } + bool CTextMessageComponent::setParentDockWidgetInfoArea(CDockWidgetInfoArea *parentDockableWidget) + { + bool c = CEnableForDockWidgetInfoArea::setParentDockWidgetInfoArea(parentDockableWidget); + c = c && connect(this->getDockWidgetInfoArea(), &CDockWidgetInfoArea::widgetTopLevelChanged, this, &CTextMessageComponent::ps_topLevelChanged); + Q_ASSERT_X(c, Q_FUNC_INFO, "Missing connect"); + return c; + } + QWidget *CTextMessageComponent::getTabWidget(CTextMessageComponent::Tab tab) const { switch (tab) diff --git a/src/blackgui/components/textmessagecomponent.h b/src/blackgui/components/textmessagecomponent.h index 1cf1c96d7..3ee242462 100644 --- a/src/blackgui/components/textmessagecomponent.h +++ b/src/blackgui/components/textmessagecomponent.h @@ -52,6 +52,9 @@ namespace BlackGui //! Destructor ~CTextMessageComponent(); + //! copydoc CEnableForDockWidgetInfoArea::setParentDockWidgetInfoArea + virtual bool setParentDockWidgetInfoArea(BlackGui::CDockWidgetInfoArea *parentDockableWidget) override; + signals: //! Message to be displayed in info window void displayInInfoWindow(const BlackMisc::CVariant &message, int displayDurationMs) const;