Skip to content

Commit

Permalink
Fixed crash caused by changes related to issue #594 - deletion of CFl…
Browse files Browse the repository at this point in the history
…oatingWidget caused crash when loading a state from XML
  • Loading branch information
githubuser0xFFFF committed Jan 26, 2024
1 parent ed6636a commit 644c828
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/DockManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ CDockManager::~CDockManager()
auto FloatingWidgets = d->FloatingWidgets;
for (auto FloatingWidget : FloatingWidgets)
{
FloatingWidget->deleteContent();
delete FloatingWidget;
}

Expand Down
18 changes: 12 additions & 6 deletions src/FloatingDockContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -760,10 +760,22 @@ CFloatingDockContainer::CFloatingDockContainer(CDockWidget *DockWidget) :
d->DockManager->notifyWidgetOrAreaRelocation(DockWidget);
}


//============================================================================
CFloatingDockContainer::~CFloatingDockContainer()
{
ADS_PRINT("~CFloatingDockContainer");
if (d->DockManager)
{
d->DockManager->removeFloatingWidget(this);
}
delete d;
}


//============================================================================
void CFloatingDockContainer::deleteContent()
{
std::vector<QPointer<ads::CDockAreaWidget>> areas;
for (int i = 0; i != dockContainer()->dockAreaCount(); ++i)
{
Expand All @@ -788,12 +800,6 @@ CFloatingDockContainer::~CFloatingDockContainer()
delete ptrWdg;
}
}

if (d->DockManager)
{
d->DockManager->removeFloatingWidget(this);
}
delete d;
}

//============================================================================
Expand Down
7 changes: 7 additions & 0 deletions src/FloatingDockContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ private Q_SLOTS:
*/
virtual void finishDragging() override;

/**
* This function deletes all dock widgets in it.
* This functions should be called only from dock manager in its
* destructor before deleting the floating widget
*/
void deleteContent();

/**
* Call this function if you just want to initialize the position
* and size of the floating widget
Expand Down

0 comments on commit 644c828

Please sign in to comment.