From a14ca9dfb8e5e7d2ce14ee9b7cc3cf3ba863d8d6 Mon Sep 17 00:00:00 2001 From: lvk88 <15655519+lvk88@users.noreply.github.com> Date: Tue, 10 Jan 2023 23:59:11 +0100 Subject: [PATCH] Issue #780: Fix crash when closing project window --- src/meshlab/mainwindow_RunTime.cpp | 4 +++- src/meshlab/multiViewer_Container.cpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/meshlab/mainwindow_RunTime.cpp b/src/meshlab/mainwindow_RunTime.cpp index 7e09ed929..df3958429 100644 --- a/src/meshlab/mainwindow_RunTime.cpp +++ b/src/meshlab/mainwindow_RunTime.cpp @@ -1811,7 +1811,9 @@ void MainWindow::newProject(const QString& projName) { if (gpumeminfo == NULL) return; - MultiViewer_Container *mvcont = new MultiViewer_Container(*gpumeminfo,mwsettings.highprecision,mwsettings.perbatchprimitives,mwsettings.minpolygonpersmoothrendering,mdiarea); + + // The parent of mvcont is set to null, because mdiArea will put it into a QMDISubWindow that will take ownership + MultiViewer_Container *mvcont = new MultiViewer_Container(*gpumeminfo,mwsettings.highprecision,mwsettings.perbatchprimitives,mwsettings.minpolygonpersmoothrendering,nullptr); connect(&mvcont->meshDoc,SIGNAL(meshAdded(int)),this,SLOT(meshAdded(int))); connect(&mvcont->meshDoc,SIGNAL(meshRemoved(int)),this,SLOT(meshRemoved(int))); connect(&mvcont->meshDoc, SIGNAL(documentUpdated()), this, SLOT(documentUpdateRequested())); diff --git a/src/meshlab/multiViewer_Container.cpp b/src/meshlab/multiViewer_Container.cpp index a5aeafcee..acdc79621 100644 --- a/src/meshlab/multiViewer_Container.cpp +++ b/src/meshlab/multiViewer_Container.cpp @@ -80,7 +80,7 @@ MultiViewer_Container::~MultiViewer_Container() //WARNING!!!! Here just the pointer to the MLSceneGLSharedDataContext is destroyed. // The data contained in the GPU gets deallocated in the closeEvent function. - delete scenecontext; + scenecontext->deleteLater(); } int MultiViewer_Container::getNextViewerId(){