Skip to content

Commit 5fad433

Browse files
Fixed a bug in restoreStateFromXml function
The function accessed the objectName from the CentralWidget even if there is no cental widget
1 parent f543318 commit 5fad433

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

src/DockManager.cpp

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -280,22 +280,25 @@ bool DockManagerPrivate::restoreStateFromXml(const QByteArray &state, int versi
280280
#endif
281281
ADS_PRINT(DockContainers);
282282

283-
const auto CentralWidgetAttribute = s.attributes().value("CentralWidget");
284-
// If we have a central widget but a state without central widget, then
285-
// something is wrong.
286-
if (CentralWidget && CentralWidgetAttribute.isEmpty())
287-
{
288-
qWarning() << "Dock manager has central widget but saved state does not have central widget.";
289-
return false;
290-
}
283+
if (CentralWidget)
284+
{
285+
const auto CentralWidgetAttribute = s.attributes().value("CentralWidget");
286+
// If we have a central widget but a state without central widget, then
287+
// something is wrong.
288+
if (CentralWidgetAttribute.isEmpty())
289+
{
290+
qWarning() << "Dock manager has central widget but saved state does not have central widget.";
291+
return false;
292+
}
291293

292-
// If the object name of the central widget does not match the name of the
293-
// saved central widget, the something is wrong
294-
if (CentralWidget->objectName() != CentralWidgetAttribute.toString())
295-
{
296-
qWarning() << "Object name of central widget does not match name of central widget in saved state.";
297-
return false;
298-
}
294+
// If the object name of the central widget does not match the name of the
295+
// saved central widget, the something is wrong
296+
if (CentralWidget->objectName() != CentralWidgetAttribute.toString())
297+
{
298+
qWarning() << "Object name of central widget does not match name of central widget in saved state.";
299+
return false;
300+
}
301+
}
299302

300303
int DockContainerCount = 0;
301304
while (s.readNextStartElement())

0 commit comments

Comments
 (0)