qgisapp: Ensure to properly delete 2D MapCanvasDock

When closing a 2D canvas dock, QGIS sometimes crashes. This is because
when the widget helper is closed, the canvas is closed. However, some
signals of the canvas widget may still be called after it is
called. Hence, the crash.

This issue is fixed by calling `deleteLater()` instead of `delete` to
ensure a proper deletion which properly takes into account the
signals.
This commit is contained in:
Jean Felder 2024-11-19 10:09:15 +01:00 committed by Nyall Dawson
parent a34442d0f3
commit 04446f9d56

View File

@ -4786,7 +4786,7 @@ QgsMapCanvasDockWidget *QgisApp::createNewMapCanvasDock( const QString &name, bo
connect( mapCanvasWidget->dockableWidgetHelper(), &QgsDockableWidgetHelper::closed, this, [ this, mapCanvasWidget] connect( mapCanvasWidget->dockableWidgetHelper(), &QgsDockableWidgetHelper::closed, this, [ this, mapCanvasWidget]
{ {
mOpen2DMapViews.remove( mapCanvasWidget ); mOpen2DMapViews.remove( mapCanvasWidget );
delete mapCanvasWidget; mapCanvasWidget->deleteLater();
markDirty(); markDirty();
} ); } );
connect( mapCanvasWidget, &QgsMapCanvasDockWidget::renameTriggered, this, &QgisApp::renameView ); connect( mapCanvasWidget, &QgsMapCanvasDockWidget::renameTriggered, this, &QgisApp::renameView );