Skip to content

Commit

Permalink
Check once for NULL graph pointer in *Curve constructors.
Browse files Browse the repository at this point in the history
Refs #7994
  • Loading branch information
martyngigg committed Sep 30, 2013
1 parent 4866c32 commit 293893c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
9 changes: 5 additions & 4 deletions Code/Mantid/MantidPlot/src/Mantid/MantidMDCurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ MantidMDCurve::MantidMDCurve(const QString& wsName,Graph* g,bool err,bool distr,
:MantidCurve(wsName, err),
m_wsName(wsName)
{
if(!g)
{
throw std::invalid_argument("MantidMDCurve::MantidMDCurve() - NULL graph pointer not allowed");
}
init(g,distr,style);
}

Expand Down Expand Up @@ -77,10 +81,7 @@ void MantidMDCurve::init(Graph* g, bool distr, Graph::CurveType style)
{
setStyle(QwtPlotCurve::Lines);
}
if (g)
{
g->insertCurve(this,lineWidth);
}
g->insertCurve(this,lineWidth);
connect(g,SIGNAL(axisScaleChanged(int,bool)),this,SLOT(axisScaleChanged(int,bool)));
observePostDelete();
connect( this, SIGNAL(resetData(const QString&)), this, SLOT(dataReset(const QString&)) );
Expand Down
11 changes: 5 additions & 6 deletions Code/Mantid/MantidPlot/src/Mantid/MantidMatrixCurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ MantidMatrixCurve::MantidMatrixCurve(const QString&,const QString& wsName,Graph*
m_wsName(wsName),
m_index(index)
{
if(!g)
{
throw std::invalid_argument("MantidMatrixCurve::MantidMatrixCurve - NULL graph pointer not allowed");
}
init(g,distr,style);
}

Expand Down Expand Up @@ -131,12 +135,7 @@ void MantidMatrixCurve::init(Graph* g,bool distr,Graph::CurveType style)
{
setStyle(QwtPlotCurve::Lines);
}


if (g)
{
g->insertCurve(this,lineWidth);
}
g->insertCurve(this,lineWidth);

// Initialise error bar colour to match curve colour
m_errorSettings->m_color = pen().color();
Expand Down

0 comments on commit 293893c

Please sign in to comment.