Fix potential crash when restoring container state (#381)

This fixes a crash which could occur when restoring the state of a floating container to a non-floating container.

This was because `ads::CDockContainerWidget::RestoreState()` will unconditionally assume this is floating if the XML has the `Floating` boolean set, and will dereference `floatingWidget()`. If this isn't floating, `floatingWidget()` will return `nullptr`, leading to a crash when it's subsequently used.

Fixes #379.
This commit is contained in:
Ben Hetherington 2021-12-03 16:01:16 +00:00 committed by GitHub
parent 21badd592e
commit 0df1a41a1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1680,7 +1680,10 @@ bool CDockContainerWidget::restoreState(CDockingStateReader& s, bool Testing)
if (!Testing)
{
CFloatingDockContainer* FloatingWidget = floatingWidget();
FloatingWidget->restoreGeometry(Geometry);
if (FloatingWidget)
{
FloatingWidget->restoreGeometry(Geometry);
}
}
}