fix crash when using widgets that delete on close

This commit is contained in:
Syarif Fakhri 2022-10-14 16:09:13 +08:00
parent 5b3ad7e5db
commit ad0c2103bf
3 changed files with 11 additions and 7 deletions

View File

@ -196,9 +196,6 @@ CAutoHideDockContainer::CAutoHideDockContainer(CDockManager* DockManager, CDockW
updateSize();
parent->registerAutoHideWidget(this);
d->DockArea->installEventFilter(this);
parent->installEventFilter(this);
}
//============================================================================
@ -231,8 +228,7 @@ CAutoHideDockContainer::~CAutoHideDockContainer()
ADS_PRINT("~CAutoHideDockContainer");
// Remove event filter in case there are any queued messages
d->DockArea->removeEventFilter(this);
parent()->removeEventFilter(this);
qApp->removeEventFilter(this);
if (d->DockManager)
{
@ -439,6 +435,8 @@ void CAutoHideDockContainer::collapseView(bool Enable)
show();
d->DockArea->show();
d->DockWidget->show();
updateMask();
updateSize();
qApp->installEventFilter(this);
}
}

View File

@ -1054,9 +1054,10 @@ bool DockContainerWidgetPrivate::restoreAutoHideDockArea(CDockingStateReader& s,
}
CDockAreaWidget* DockArea = nullptr;
CAutoHideDockContainer* dockContainer = nullptr;
if (!Testing)
{
const auto dockContainer = new CAutoHideDockContainer(DockManager, area, _this);
dockContainer = new CAutoHideDockContainer(DockManager, area, _this);
if (!dockContainer->restoreState(s, Testing))
{
return false;
@ -1108,6 +1109,11 @@ bool DockContainerWidgetPrivate::restoreAutoHideDockArea(CDockingStateReader& s,
DockArea->autoHideDockContainer()->toggleView(!Closed);
}
if (dockContainer && !dockContainer->dockWidget())
{
dockContainer->cleanupAndDelete();
}
return true;
}

View File

@ -248,7 +248,7 @@ void DockWidgetPrivate::updateParentDockArea()
void DockWidgetPrivate::closeAutoHideDockWidgetsIfNeeded()
{
if (_this->dockContainer() && _this->dockContainer()->openedDockWidgets().isEmpty())
if (_this->dockContainer() && _this->dockContainer()->openedDockWidgets().isEmpty() && !_this->dockManager()->isRestoringState())
{
for (auto autoHideWidget : _this->dockContainer()->autoHideWidgets())
{