From 5fad43377b318daee42666e116d6d851d7d05f75 Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Fri, 25 Sep 2020 14:40:28 +0200 Subject: [PATCH] Fixed a bug in restoreStateFromXml function The function accessed the objectName from the CentralWidget even if there is no cental widget --- src/DockManager.cpp | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/DockManager.cpp b/src/DockManager.cpp index 0529321..16b2d01 100644 --- a/src/DockManager.cpp +++ b/src/DockManager.cpp @@ -280,22 +280,25 @@ bool DockManagerPrivate::restoreStateFromXml(const QByteArray &state, int versi #endif ADS_PRINT(DockContainers); - const auto CentralWidgetAttribute = s.attributes().value("CentralWidget"); - // If we have a central widget but a state without central widget, then - // something is wrong. - if (CentralWidget && CentralWidgetAttribute.isEmpty()) - { - qWarning() << "Dock manager has central widget but saved state does not have central widget."; - return false; - } + if (CentralWidget) + { + const auto CentralWidgetAttribute = s.attributes().value("CentralWidget"); + // If we have a central widget but a state without central widget, then + // something is wrong. + if (CentralWidgetAttribute.isEmpty()) + { + qWarning() << "Dock manager has central widget but saved state does not have central widget."; + return false; + } - // If the object name of the central widget does not match the name of the - // saved central widget, the something is wrong - if (CentralWidget->objectName() != CentralWidgetAttribute.toString()) - { - qWarning() << "Object name of central widget does not match name of central widget in saved state."; - return false; - } + // If the object name of the central widget does not match the name of the + // saved central widget, the something is wrong + if (CentralWidget->objectName() != CentralWidgetAttribute.toString()) + { + qWarning() << "Object name of central widget does not match name of central widget in saved state."; + return false; + } + } int DockContainerCount = 0; while (s.readNextStartElement())