Skip to content

Commit

Permalink
Fixes for crashes after reducing number of axis
Browse files Browse the repository at this point in the history
  • Loading branch information
kriben authored and magnesj committed Jan 3, 2024
1 parent d948bfa commit 293ba9b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/qwt_plot_axis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -770,14 +770,14 @@ void QwtPlot::updateAxes()
{
const QRectF rect = item->boundingRect();

if ( rect.width() >= 0.0 )
if ( isAxisValid( item->xAxis()) && rect.width() >= 0.0 )
{
const QwtAxisId xAxis = item->xAxis();
boundingIntervals[ xAxis.pos ][ xAxis.id ] |=
QwtInterval( rect.left(), rect.right() );
}

if ( rect.height() >= 0.0 )
if ( isAxisValid( item->yAxis()) && rect.height() >= 0.0 )
{
const QwtAxisId yAxis = item->yAxis();
boundingIntervals[ yAxis.pos ][ yAxis.id ] |=
Expand Down Expand Up @@ -831,7 +831,8 @@ void QwtPlot::updateAxes()
for ( it = itmList.begin(); it != itmList.end(); ++it )
{
QwtPlotItem* item = *it;
if ( item->testItemInterest( QwtPlotItem::ScaleInterest ) )
if ( item->testItemInterest( QwtPlotItem::ScaleInterest ) &&
isAxisValid( item->xAxis() ) && isAxisValid( item->yAxis() ) )
{
item->updateScaleDiv( axisScaleDiv( item->xAxis() ),
axisScaleDiv( item->yAxis() ) );
Expand Down
3 changes: 3 additions & 0 deletions src/qwt_plot_curve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,9 @@ int QwtPlotCurve::closestPoint( const QPointF& pos, double* dist ) const
if ( plot() == NULL || numSamples <= 0 )
return -1;

if ( !plot()->isAxisValid( xAxis() ) || !plot()->isAxisValid( yAxis() ) )
return -1;

const QwtSeriesData< QPointF >* series = data();

const QwtScaleMap xMap = plot()->canvasMap( xAxis() );
Expand Down

0 comments on commit 293ba9b

Please sign in to comment.