From 06cda96e6090deb51bfd201a37979b7f80ef9113 Mon Sep 17 00:00:00 2001 From: Guido Ranzuglia granzuglia Date: Thu, 22 Sep 2016 06:02:55 +0000 Subject: [PATCH] - fixed "closing mesh document" crash --- src/meshlab/mainwindow.h | 1 + src/meshlab/mainwindow_Init.cpp | 6 ------ src/meshlab/mainwindow_RunTime.cpp | 15 ++++++++++++--- src/meshlab/multiViewer_Container.cpp | 3 +++ src/meshlab/multiViewer_Container.h | 1 + 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/meshlab/mainwindow.h b/src/meshlab/mainwindow.h index 410757670..0b7ebdd73 100644 --- a/src/meshlab/mainwindow.h +++ b/src/meshlab/mainwindow.h @@ -164,6 +164,7 @@ public: void updateSharedContextDataAfterFilterExecution(int postcondmask,int fclasses,bool& newmeshcreated); private slots: + void closeCurrentDocument(); //////////// Slot Menu File ////////////////////// void reload(); void reloadAllMesh(); diff --git a/src/meshlab/mainwindow_Init.cpp b/src/meshlab/mainwindow_Init.cpp index 4f04489a4..b5fa52215 100644 --- a/src/meshlab/mainwindow_Init.cpp +++ b/src/meshlab/mainwindow_Init.cpp @@ -76,12 +76,6 @@ MainWindow::MainWindow() connect(windowMapper, SIGNAL(mapped(QWidget*)), this, SLOT(wrapSetActiveSubWindow(QWidget *))); // Quando si passa da una finestra all'altra aggiorna lo stato delle toolbar e dei menu connect(mdiarea, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(switchCurrentContainer(QMdiSubWindow *))); - connect(mdiarea, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(updateLayerDialog())); - connect(mdiarea, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(updateMenus())); - connect(mdiarea, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(updateWindowMenu())); - connect(mdiarea, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(updateStdDialog())); - connect(mdiarea, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(updateXMLStdDialog())); - connect(mdiarea, SIGNAL(subWindowActivated(QMdiSubWindow *)), this, SLOT(updateDocumentScriptBindings())); httpReq = new QNetworkAccessManager(this); connect(httpReq, SIGNAL(finished(QNetworkReply*)), this, SLOT(connectionDone(QNetworkReply*))); diff --git a/src/meshlab/mainwindow_RunTime.cpp b/src/meshlab/mainwindow_RunTime.cpp index 764f0225f..b9eb00b23 100644 --- a/src/meshlab/mainwindow_RunTime.cpp +++ b/src/meshlab/mainwindow_RunTime.cpp @@ -495,12 +495,12 @@ while(ii < meshDoc()->meshList.size()) a->setEnabled(false); } - - if(GLA()) + GLArea* tmp = GLA(); + if(tmp != NULL) { showLayerDlgAct->setChecked(layerDialog->isVisible()); showRasterAct->setEnabled(meshDoc()->rm() != 0); - showRasterAct->setChecked(GLA()->isRaster()); + showRasterAct->setChecked(tmp->isRaster()); } else { @@ -2394,6 +2394,7 @@ void MainWindow::newProject(const QString& projName) 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())); + connect(mvcont, SIGNAL(closingMultiViewerContainer()), this, SLOT(closeCurrentDocument())); mdiarea->addSubWindow(mvcont); connect(mvcont,SIGNAL(updateMainWindowMenus()),this,SLOT(updateMenus())); connect(mvcont,SIGNAL(updateDocumentViewer()),this,SLOT(updateLayerDialog())); @@ -3744,4 +3745,12 @@ void MainWindow::switchCurrentContainer(QMdiSubWindow * subwin) updateXMLStdDialog(); updateDocumentScriptBindings(); } +} + +void MainWindow::closeCurrentDocument() +{ + _currviewcontainer = NULL; + layerDialog->setVisible(false); + if (mdiarea != NULL) + mdiarea->closeActiveSubWindow(); } \ No newline at end of file diff --git a/src/meshlab/multiViewer_Container.cpp b/src/meshlab/multiViewer_Container.cpp index 728fd8652..35091d3f6 100644 --- a/src/meshlab/multiViewer_Container.cpp +++ b/src/meshlab/multiViewer_Container.cpp @@ -356,7 +356,10 @@ void MultiViewer_Container::closeEvent( QCloseEvent *event ) } if (close) + { + emit closingMultiViewerContainer(); event->accept(); + } else event->ignore(); } diff --git a/src/meshlab/multiViewer_Container.h b/src/meshlab/multiViewer_Container.h index 92fcf7843..d5c4d107b 100644 --- a/src/meshlab/multiViewer_Container.h +++ b/src/meshlab/multiViewer_Container.h @@ -111,6 +111,7 @@ public: signals: void updateMainWindowMenus(); //updates the menus of the meshlab MainWindow void updateDocumentViewer(); + void closingMultiViewerContainer(); public slots: