Skip to content

Commit 644c828

Browse files
Fixed crash caused by changes related to issue #594 - deletion of CFloatingWidget caused crash when loading a state from XML
1 parent ed6636a commit 644c828

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

src/DockManager.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,7 @@ CDockManager::~CDockManager()
566566
auto FloatingWidgets = d->FloatingWidgets;
567567
for (auto FloatingWidget : FloatingWidgets)
568568
{
569+
FloatingWidget->deleteContent();
569570
delete FloatingWidget;
570571
}
571572

src/FloatingDockContainer.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -760,10 +760,22 @@ CFloatingDockContainer::CFloatingDockContainer(CDockWidget *DockWidget) :
760760
d->DockManager->notifyWidgetOrAreaRelocation(DockWidget);
761761
}
762762

763+
763764
//============================================================================
764765
CFloatingDockContainer::~CFloatingDockContainer()
765766
{
766767
ADS_PRINT("~CFloatingDockContainer");
768+
if (d->DockManager)
769+
{
770+
d->DockManager->removeFloatingWidget(this);
771+
}
772+
delete d;
773+
}
774+
775+
776+
//============================================================================
777+
void CFloatingDockContainer::deleteContent()
778+
{
767779
std::vector<QPointer<ads::CDockAreaWidget>> areas;
768780
for (int i = 0; i != dockContainer()->dockAreaCount(); ++i)
769781
{
@@ -788,12 +800,6 @@ CFloatingDockContainer::~CFloatingDockContainer()
788800
delete ptrWdg;
789801
}
790802
}
791-
792-
if (d->DockManager)
793-
{
794-
d->DockManager->removeFloatingWidget(this);
795-
}
796-
delete d;
797803
}
798804

799805
//============================================================================

src/FloatingDockContainer.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,13 @@ private Q_SLOTS:
146146
*/
147147
virtual void finishDragging() override;
148148

149+
/**
150+
* This function deletes all dock widgets in it.
151+
* This functions should be called only from dock manager in its
152+
* destructor before deleting the floating widget
153+
*/
154+
void deleteContent();
155+
149156
/**
150157
* Call this function if you just want to initialize the position
151158
* and size of the floating widget

0 commit comments

Comments
 (0)