Skip to content

Commit

Permalink
Fix uninitialized wheel zoom factor in QgsMapCanvas
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 29, 2016
1 parent 7cab60b commit 5b6f9d8
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions src/gui/qgsmapcanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand All @@ -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 );

Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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();
Expand Down

4 comments on commit 5b6f9d8

@3nids
Copy link
Member

@3nids 3nids commented on 5b6f9d8 May 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@nyalldawson
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, tests are all fixed now.

@3nids
Copy link
Member

@3nids 3nids commented on 5b6f9d8 May 30, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks a lot!

Please sign in to comment.