qgsplotcanvas: Fix mousePressEvent when no tool is set

In that case, `mTool->flags()` cannot be checked. Fix the issue by
also checking that `mTool` is set.

Closes: https://github.com/qgis/QGIS/issues/62800
This commit is contained in:
Jean Felder 2025-08-07 19:46:42 +02:00 committed by Andrea Giudiceandrea
parent f0ae7ee526
commit aa1d78cbea

View File

@ -166,7 +166,7 @@ void QgsPlotCanvas::mousePressEvent( QMouseEvent *event )
setTool( mMidMouseButtonPanTool ); setTool( mMidMouseButtonPanTool );
event->accept(); event->accept();
} }
else if ( event->button() == Qt::RightButton && mTool->flags() & Qgis::PlotToolFlag::ShowContextMenu ) else if ( event->button() == Qt::RightButton && mTool && mTool->flags() & Qgis::PlotToolFlag::ShowContextMenu )
{ {
auto me = std::make_unique<QgsPlotMouseEvent>( this, event ); auto me = std::make_unique<QgsPlotMouseEvent>( this, event );
showContextMenu( me.get() ); showContextMenu( me.get() );