From 8b3f980079effecfd08f920266b995e35d04f626 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Mon, 2 Apr 2018 10:17:09 +0200 Subject: [PATCH] Fix crash on selection when there's no MohrsCirclePlot * Check if the pointer is valid before dereferencing --- .../UserInterface/RiuSelectionChangedHandler.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp b/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp index ab27893372..513c716578 100644 --- a/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp +++ b/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp @@ -90,7 +90,8 @@ void RiuSelectionChangedHandler::handleSelectionDeleted() const RiuPvtPlotUpdater* pvtPlotUpdater = RiuMainWindow::instance()->pvtPlotPanel()->plotUpdater(); pvtPlotUpdater->updateOnSelectionChanged(nullptr); - RiuMainWindow::instance()->mohrsCirclePlot()->clearPlot(); + RiuMohrsCirclePlot* mohrsCirclePlot = RiuMainWindow::instance()->mohrsCirclePlot(); + if (mohrsCirclePlot) mohrsCirclePlot->clearPlot(); updateResultInfo(nullptr); @@ -110,7 +111,8 @@ void RiuSelectionChangedHandler::handleItemAppended(const RiuSelectionItem* item RiuPvtPlotUpdater* pvtPlotUpdater = RiuMainWindow::instance()->pvtPlotPanel()->plotUpdater(); pvtPlotUpdater->updateOnSelectionChanged(item); - RiuMainWindow::instance()->mohrsCirclePlot()->appendSelection(item); + RiuMohrsCirclePlot* mohrsCirclePlot = RiuMainWindow::instance()->mohrsCirclePlot(); + if (mohrsCirclePlot) mohrsCirclePlot->appendSelection(item); updateResultInfo(item); @@ -124,7 +126,8 @@ void RiuSelectionChangedHandler::handleSetSelectedItem(const RiuSelectionItem* i { RiuMainWindow::instance()->resultPlot()->deleteAllCurves(); - RiuMainWindow::instance()->mohrsCirclePlot()->clearPlot(); + RiuMohrsCirclePlot* mohrsCirclePlot = RiuMainWindow::instance()->mohrsCirclePlot(); + if (mohrsCirclePlot) mohrsCirclePlot->clearPlot(); handleItemAppended(item); }