diff --git a/qt/widgets/plotting/src/Mpl/ContourPreviewPlot.cpp b/qt/widgets/plotting/src/Mpl/ContourPreviewPlot.cpp index 599e863bfc554bd38ff9343eccfa2ae6f91ae4ba..5794aa61c126871e95533ee4ad6ad7254de20cf4 100644 --- a/qt/widgets/plotting/src/Mpl/ContourPreviewPlot.cpp +++ b/qt/widgets/plotting/src/Mpl/ContourPreviewPlot.cpp @@ -68,11 +68,15 @@ void ContourPreviewPlot::onWorkspaceRemoved( if (auto workspace = boost::dynamic_pointer_cast<MatrixWorkspace>(nf->object())) { // If the artist has already been removed, ignore. + bool workspaceRemoved = false; try { - m_canvas->gca<MantidAxes>().removeWorkspaceArtists(workspace); + workspaceRemoved = + m_canvas->gca<MantidAxes>().removeWorkspaceArtists(workspace); } catch (Mantid::PythonInterface::PythonException &) { } - m_canvas->draw(); + if (workspaceRemoved) { + m_canvas->draw(); + } } } @@ -86,8 +90,9 @@ void ContourPreviewPlot::onWorkspaceReplaced( boost::dynamic_pointer_cast<MatrixWorkspace>(nf->oldObject())) { if (auto newWorkspace = boost::dynamic_pointer_cast<MatrixWorkspace>(nf->newObject())) { - m_canvas->gca<MantidAxes>().replaceWorkspaceArtists(newWorkspace); - m_canvas->draw(); + if (m_canvas->gca<MantidAxes>().replaceWorkspaceArtists(newWorkspace)) { + m_canvas->draw(); + } } } }