Fix crash on selection when there's no MohrsCirclePlot

* Check if the pointer is valid before dereferencing
This commit is contained in:
Gaute Lindkvist committed 2018-04-02 10:17:09 +02:00
1 parent 1a6c529488
commit 8b3f980079
1 file changed
+6 -3
@@ -90,7 +90,8 @@ void RiuSelectionChangedHandler::handleSelectionDeleted() const
RiuPvtPlotUpdater* pvtPlotUpdater = RiuMainWindow::instance()->pvtPlotPanel()->plotUpdater(); RiuPvtPlotUpdater* pvtPlotUpdater = RiuMainWindow::instance()->pvtPlotPanel()->plotUpdater();
pvtPlotUpdater->updateOnSelectionChanged(nullptr); pvtPlotUpdater->updateOnSelectionChanged(nullptr);
RiuMainWindow::instance()->mohrsCirclePlot()->clearPlot(); RiuMohrsCirclePlot* mohrsCirclePlot = RiuMainWindow::instance()->mohrsCirclePlot();
if (mohrsCirclePlot) mohrsCirclePlot->clearPlot();
updateResultInfo(nullptr); updateResultInfo(nullptr);
@@ -110,7 +111,8 @@ void RiuSelectionChangedHandler::handleItemAppended(const RiuSelectionItem* item
RiuPvtPlotUpdater* pvtPlotUpdater = RiuMainWindow::instance()->pvtPlotPanel()->plotUpdater(); RiuPvtPlotUpdater* pvtPlotUpdater = RiuMainWindow::instance()->pvtPlotPanel()->plotUpdater();
pvtPlotUpdater->updateOnSelectionChanged(item); pvtPlotUpdater->updateOnSelectionChanged(item);
RiuMainWindow::instance()->mohrsCirclePlot()->appendSelection(item); RiuMohrsCirclePlot* mohrsCirclePlot = RiuMainWindow::instance()->mohrsCirclePlot();
if (mohrsCirclePlot) mohrsCirclePlot->appendSelection(item);
updateResultInfo(item); updateResultInfo(item);
@@ -124,7 +126,8 @@ void RiuSelectionChangedHandler::handleSetSelectedItem(const RiuSelectionItem* i
{ {
RiuMainWindow::instance()->resultPlot()->deleteAllCurves(); RiuMainWindow::instance()->resultPlot()->deleteAllCurves();
RiuMainWindow::instance()->mohrsCirclePlot()->clearPlot(); RiuMohrsCirclePlot* mohrsCirclePlot = RiuMainWindow::instance()->mohrsCirclePlot();
if (mohrsCirclePlot) mohrsCirclePlot->clearPlot();
handleItemAppended(item); handleItemAppended(item);
} }