Skip to content
Permalink
Browse files

Fix uninitialized wheel zoom factor in QgsMapCanvas

  • Loading branch information
nyalldawson committed May 29, 2016
1 parent 7cab60b commit 5b6f9d846eff62a33d3af5db68c0679b5462948e
Showing with 17 additions and 15 deletions.
  1. +17 −15 src/gui/qgsmapcanvas.cpp
@@ -189,12 +189,25 @@ void QgsMapCanvasRendererSync::onLayersC2R()
QgsMapCanvas::QgsMapCanvas( QWidget * parent, const char *name )
: QGraphicsView( parent )
, mCanvasProperties( new CanvasProperties )
, mMapRenderer( nullptr )
, mMap( nullptr )
, mMapOverview( nullptr )
, mFrozen( false )
, mRefreshScheduled( false )
, mRenderFlag( true ) // by default, the canvas is rendered
, mCurrentLayer( nullptr )
, mScene( nullptr )
, mMapTool( nullptr )
, mLastNonZoomMapTool( nullptr )
, mLastExtentIndex( -1 )
, mWheelZoomFactor( 2.0 )
, mJob( nullptr )
, mJobCancelled( false )
, mLabelingResults( nullptr )
, mUseParallelRendering( false )
, mDrawRenderingStats( false )
, mCache( nullptr )
, mResizeTimer( nullptr )
, mPreviewEffect( nullptr )
, mSnappingUtils( nullptr )
, mScaleLocked( false )
@@ -205,18 +218,6 @@ QgsMapCanvas::QgsMapCanvas( QWidget * parent, const char *name )
setScene( mScene );
setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
mLastExtentIndex = -1;
mCurrentLayer = nullptr;
mMapOverview = nullptr;
mMapTool = nullptr;
mLastNonZoomMapTool = nullptr;

mFrozen = false;
mRefreshScheduled = false;

// by default, the canvas is rendered
mRenderFlag = true;

setMouseTracking( true );
setFocusPolicy( Qt::StrongFocus );

@@ -245,6 +246,8 @@ QgsMapCanvas::QgsMapCanvas( QWidget * parent, const char *name )
mSettings.setSegmentationTolerance( segmentationTolerance );
mSettings.setSegmentationToleranceType( toleranceType );

mWheelZoomFactor = settings.value( "/qgis/zoom_factor", 2 ).toDouble();

// class that will sync most of the changes between canvas and (legacy) map renderer
// it is parented to map canvas, will be deleted automatically
new QgsMapCanvasRendererSync( this, mMapRenderer );
@@ -322,11 +325,10 @@ void QgsMapCanvas::setMagnificationFactor( double factor )
QSettings settings;
double magnifierMin = settings.value( "/qgis/magnifier_factor_min", 0.1 ).toDouble();
double magnifierMax = settings.value( "/qgis/magnifier_factor_max", 10 ).toDouble();
factor = factor > magnifierMax ? magnifierMax : factor;
factor = factor < magnifierMin ? magnifierMin : factor;
factor = qBound( magnifierMin, factor, magnifierMax );

// the magnifier widget is in integer percent
if ( qAbs( factor - mSettings.magnificationFactor() ) >= 0.01 )
if ( !qgsDoubleNear( factor, mSettings.magnificationFactor(), 0.01 ) )
{
mSettings.setMagnificationFactor( factor );
refresh();

4 comments on commit 5b6f9d8

@3nids

This comment has been minimized.

Copy link
Member

@3nids 3nids replied May 29, 2016

Thanks for this, at least part of it.
I will try to look at the failing test tomorrow if Paul doesn't fix it until then ;-)

Depending on what happened to the QGIS crew yesterday evening !

@nyalldawson

This comment has been minimized.

Copy link
Collaborator Author

@nyalldawson nyalldawson replied May 29, 2016

@3nids all good - not your fault. You just managed to expose an existing bug.

@nyalldawson

This comment has been minimized.

Copy link
Collaborator Author

@nyalldawson nyalldawson replied May 29, 2016

Also, tests are all fixed now.

@3nids

This comment has been minimized.

Copy link
Member

@3nids 3nids replied May 30, 2016

thanks a lot!

Please sign in to comment.
You can’t perform that action at this time.