From a4bd3a830f4555b09559642c40d798892450bfa4 Mon Sep 17 00:00:00 2001 From: Martyn Gigg <martyn.gigg@stfc.ac.uk> Date: Mon, 16 Jul 2018 09:16:04 +0100 Subject: [PATCH] Fixes segfault in project saving with hidden VSI The VSI window hides itself on close but removes all sources from the pipeline. There is now a check that there are active sources available before attempting to save the VSI to a project. Refs #22914 --- .../VatesSimpleGui/ViewWidgets/src/MdViewerWidget.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/qt/paraview_ext/VatesSimpleGui/ViewWidgets/src/MdViewerWidget.cpp b/qt/paraview_ext/VatesSimpleGui/ViewWidgets/src/MdViewerWidget.cpp index 5123d319ff9..001c03fc090 100644 --- a/qt/paraview_ext/VatesSimpleGui/ViewWidgets/src/MdViewerWidget.cpp +++ b/qt/paraview_ext/VatesSimpleGui/ViewWidgets/src/MdViewerWidget.cpp @@ -1054,6 +1054,10 @@ void MdViewerWidget::setActiveObjects(pqView *view, pqPipelineSource *source) { */ std::string MdViewerWidget::saveToProject(ApplicationWindow *app) { UNUSED_ARG(app); + // Early exit if there are no sources + auto &activeObjects = pqActiveObjects::instance(); + if (!activeObjects.activeSource()) + return ""; TSVSerialiser tsv, contents; // save window position & size @@ -1064,7 +1068,7 @@ std::string MdViewerWidget::saveToProject(ApplicationWindow *app) { auto fileName = workingDir.toStdString() + "/VSI.xml"; // Dump the state of VSI to a XML file - auto session = pqActiveObjects::instance().activeServer()->proxyManager(); + auto session = activeObjects.activeServer()->proxyManager(); session->SaveXMLState(fileName.c_str()); contents.writeLine("FileName") << fileName; @@ -1072,7 +1076,6 @@ std::string MdViewerWidget::saveToProject(ApplicationWindow *app) { auto vtype = currentView->getViewType(); contents.writeLine("ViewType") << static_cast<int>(vtype); - auto &activeObjects = pqActiveObjects::instance(); auto proxyManager = activeObjects.activeServer()->proxyManager(); auto view = activeObjects.activeView()->getProxy(); auto source = activeObjects.activeSource()->getProxy(); -- GitLab