From 0d27351e11b528273e42227c8073f69c9827b454 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Wed, 23 Sep 2015 20:02:06 +0200 Subject: [PATCH] Improved asserts/comments in dock widget class --- src/blackgui/dockwidget.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/blackgui/dockwidget.cpp b/src/blackgui/dockwidget.cpp index 6e97f0efb..30d2fe93f 100644 --- a/src/blackgui/dockwidget.cpp +++ b/src/blackgui/dockwidget.cpp @@ -393,15 +393,19 @@ namespace BlackGui if (!this->m_allowStatusBar) { return; } this->m_statusBar.initStatusBar(); - // we expect the following hierarchy - // QDockWidget (CDockWidget/CDockWidgetInfoArea) -> QWidget (outer widget) -> QFrame (inner widget) - // Structure used for frameless floating windows - - QWidget *outerWidget = this->widget(); // the inner widget containing the layout + // Typical reasons for asserts here + // 1) Check the structwe, we expect the following hierarchy + // QDockWidget (CDockWidget/CDockWidgetInfoArea) -> QWidget (outer widget) -> QFrame (inner widget) + // Structure used for frameless floating windows + // 2) Check if the "floating" flag is accidentally set for the dock widget in the GUI builder + // 3) Is the dock widget promoted BlackGui::CDockWidgetInfoArea? + QWidget *outerWidget = this->widget(); // the outer widget containing the layout Q_ASSERT_X(outerWidget, "CDockWidget::initStatusBar", "No outer widget"); + if (!outerWidget) { return; } Q_ASSERT_X(outerWidget->layout(), "CDockWidget::initStatusBar", "No outer widget layout"); + if (!outerWidget->layout()) { return; } Q_ASSERT_X(outerWidget->layout()->itemAt(0) && outerWidget->layout()->itemAt(0)->widget(), "CDockWidget::initStatusBar", "No outer widget layout item"); - if (!outerWidget || !outerWidget->layout() || !outerWidget->layout()->itemAt(0) || !outerWidget->layout()->itemAt(0)->widget()) { this->m_allowStatusBar = false; return; } + if (!outerWidget->layout()->itemAt(0) || !outerWidget->layout()->itemAt(0)->widget()) { this->m_allowStatusBar = false; return; } // Inner widget is supposed to be a QFrame / promoted QFrame QFrame *innerWidget = qobject_cast(outerWidget->layout()->itemAt(0)->widget()); // the inner widget containing the layout