Skip to content

Commit 2555d28

Browse files
committed
[composer] Fix use of uninitialized member (unlikely to occur outside of tests)
1 parent 4f7caa0 commit 2555d28

File tree

2 files changed

+20
-62
lines changed

2 files changed

+20
-62
lines changed

src/core/composer/qgscomposermap.cpp

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -48,35 +48,11 @@
4848

4949
QgsComposerMap::QgsComposerMap( QgsComposition *composition, int x, int y, int width, int height )
5050
: QgsComposerItem( x, y, width, height, composition )
51-
, mGridStack( nullptr )
52-
, mOverviewStack( nullptr )
53-
, mMapRotation( 0 )
54-
, mEvaluatedMapRotation( 0 )
55-
, mKeepLayerSet( false )
56-
, mKeepLayerStyles( false )
57-
, mFollowVisibilityPreset( false )
58-
, mUpdatesEnabled( true )
59-
, mDrawAnnotations( true )
60-
, mAtlasDriven( false )
61-
, mAtlasScalingMode( Auto )
62-
, mAtlasMargin( 0.10 )
63-
{
64-
mComposition = composition;
65-
66-
mId = 0;
51+
{
6752
assignFreeId();
6853

69-
mPreviewMode = QgsComposerMap::Rectangle;
7054
mCurrentRectangle = rect();
7155

72-
// Cache
73-
mCacheUpdated = false;
74-
mDrawing = false;
75-
76-
//Offset
77-
mXOffset = 0.0;
78-
mYOffset = 0.0;
79-
8056
QgsProject* project = mComposition->project();
8157

8258
//get the color for map canvas background and set map background color accordingly
@@ -92,26 +68,8 @@ QgsComposerMap::QgsComposerMap( QgsComposition *composition, int x, int y, int w
9268

9369
QgsComposerMap::QgsComposerMap( QgsComposition *composition )
9470
: QgsComposerItem( 0, 0, 10, 10, composition )
95-
, mGridStack( nullptr )
96-
, mOverviewStack( nullptr )
97-
, mMapRotation( 0 )
98-
, mEvaluatedMapRotation( 0 )
99-
, mKeepLayerSet( false )
100-
, mKeepLayerStyles( false )
101-
, mFollowVisibilityPreset( false )
102-
, mUpdatesEnabled( true )
103-
, mDrawAnnotations( true )
104-
, mAtlasDriven( false )
105-
, mAtlasScalingMode( Auto )
106-
, mAtlasMargin( 0.10 )
107-
{
108-
//Offset
109-
mXOffset = 0.0;
110-
mYOffset = 0.0;
111-
112-
mComposition = composition;
71+
{
11372
mId = mComposition->composerMapItems().size();
114-
mPreviewMode = QgsComposerMap::Rectangle;
11573
mCurrentRectangle = rect();
11674

11775
init();

src/core/composer/qgscomposermap.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -493,11 +493,11 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
493493
private:
494494

495495
//! Unique identifier
496-
int mId;
496+
int mId = 0;
497497

498-
QgsComposerMapGridStack* mGridStack;
498+
QgsComposerMapGridStack* mGridStack = nullptr;
499499

500-
QgsComposerMapOverviewStack* mOverviewStack;
500+
QgsComposerMapOverviewStack* mOverviewStack = nullptr;
501501

502502
// Map region in map units really used for rendering
503503
// It can be the same as mUserExtent, but it can be bigger in on dimension if mCalculate==Scale,
@@ -516,50 +516,50 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
516516
QImage mCacheImage;
517517

518518
// Is cache up to date
519-
bool mCacheUpdated;
519+
bool mCacheUpdated = false;
520520

521521
//! \brief Preview style
522-
PreviewMode mPreviewMode;
522+
PreviewMode mPreviewMode = QgsComposerMap::Rectangle;
523523

524524
//! \brief Number of layers when cache was created
525525
int mNumCachedLayers;
526526

527527
//! \brief set to true if in state of drawing. Concurrent requests to draw method are returned if set to true
528-
bool mDrawing;
528+
bool mDrawing = false;
529529

530530
//! Offset in x direction for showing map cache image
531-
double mXOffset;
531+
double mXOffset = 0.0;
532532
//! Offset in y direction for showing map cache image
533-
double mYOffset;
533+
double mYOffset = 0.0;
534534

535535
//! Map rotation
536-
double mMapRotation;
536+
double mMapRotation = 0;
537537

538538
/** Temporary evaluated map rotation. Data defined rotation may mean this value
539539
* differs from mMapRotation*/
540-
double mEvaluatedMapRotation;
540+
double mEvaluatedMapRotation = 0;
541541

542542
//! Flag if layers to be displayed should be read from qgis canvas (true) or from stored list in mLayerSet (false)
543-
bool mKeepLayerSet;
543+
bool mKeepLayerSet = false;
544544

545545
//! Stored layer list (used if layer live-link mKeepLayerSet is disabled)
546546
QgsWeakMapLayerPointerList mLayers;
547547

548-
bool mKeepLayerStyles;
548+
bool mKeepLayerStyles = false;
549549
//! Stored style names (value) to be used with particular layer IDs (key) instead of default style
550550
QMap<QString, QString> mLayerStyleOverrides;
551551

552552
/** Whether layers and styles should be used from a preset (preset name is stored
553553
* in mVisibilityPresetName and may be overridden by data-defined expression).
554554
* This flag has higher priority than mKeepLayerSet. */
555-
bool mFollowVisibilityPreset;
555+
bool mFollowVisibilityPreset = false;
556556

557557
/** Map theme name to be used for map's layers and styles in case mFollowVisibilityPreset
558558
* is true. May be overridden by data-defined expression. */
559559
QString mFollowVisibilityPresetName;
560560

561561
//! Whether updates to the map are enabled
562-
bool mUpdatesEnabled;
562+
bool mUpdatesEnabled = true;
563563

564564
//! Establishes signal/slot connection for update in case of layer change
565565
void connectUpdateSlot();
@@ -576,18 +576,18 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
576576
//! Current bounding rectangle. This is used to check if notification to the graphics scene is necessary
577577
QRectF mCurrentRectangle;
578578
//! True if annotation items, rubber band, etc. from the main canvas should be displayed
579-
bool mDrawAnnotations;
579+
bool mDrawAnnotations = true;
580580

581581
/** Adjusts an extent rectangle to match the provided item width and height, so that extent
582582
* center of extent remains the same */
583583
void adjustExtentToItemShape( double itemWidth, double itemHeight, QgsRectangle& extent ) const;
584584

585585
//! True if map is being controlled by an atlas
586-
bool mAtlasDriven;
586+
bool mAtlasDriven = false;
587587
//! Current atlas scaling mode
588-
AtlasScalingMode mAtlasScalingMode;
588+
AtlasScalingMode mAtlasScalingMode = Auto;
589589
//! Margin size for atlas driven extents (percentage of feature size) - when in auto scaling mode
590-
double mAtlasMargin;
590+
double mAtlasMargin = 0.10;
591591

592592
void init();
593593

0 commit comments

Comments
 (0)