Skip to content
Snippets Groups Projects
Commit d5a6a71b authored by Owen Arnold's avatar Owen Arnold
Browse files

Merge pull request #353 from...

Merge pull request #353 from mantidproject/bugfix/11045_fix_crash_when_deleting_peaks_ws_in_splatterplot

Fix crash when reloading a deleted peaks workspace in splatterplot mode in the VSI
parents ed39e8a3 c256be87
No related branches found
No related tags found
No related merge requests found
......@@ -95,6 +95,8 @@ signals:
public slots:
/// Check the coordinates for the peaks overlay if necessary
void checkPeaksCoordinates();
/// Listen to destruction of peak sources
void onPeakSourceDestroyed();
protected slots:
/// Check state of toggle button with respect to peak coordinates.
......
......@@ -162,6 +162,9 @@ void SplatterPlotView::render()
{
this->peaksSource.append(src);
renderType = "Wireframe";
// Connect the peak source to a listener, to detect its destruction
QObject::connect(src, SIGNAL(destroyed()),
this, SLOT(onPeakSourceDestroyed()));
}
// Show the data
......@@ -308,6 +311,34 @@ void SplatterPlotView::destroyPeakSources()
this->peaksSource.clear();
}
/**
* React to the destruction of a peak source, mainly unregister it from the peakSource container
*/
void SplatterPlotView::onPeakSourceDestroyed() {
pqServer *server = pqActiveObjects::instance().activeServer();
pqServerManagerModel *smModel = pqApplicationCore::instance()->getServerManagerModel();
QList<pqPipelineSource *> sources;
sources = smModel->findItems<pqPipelineSource *>(server);
// Check for each source in the peakSource container, if it still is an existing source
for (QList<QPointer<pqPipelineSource>>::Iterator it = peaksSource.begin(); it != peaksSource.end();) {
bool foundSource = false;
for (QList<pqPipelineSource*>::Iterator source = sources.begin(); source != sources.end(); ++source) {
// Check if the source registered in PV matches our current peak source
if ((*source) == (*it)) {
foundSource = true;
}
}
if (!foundSource) {
it = peaksSource.erase(it);
}
else {
++it;
}
}
}
/**
* This function reads the coordinates from the probe point plugin and
* passes them on to a listening serivce that will handle them in the
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment