Skip to content

Commit 83bb33c

Browse files
committedJul 5, 2015
cleanup composer test map settings
1 parent 3856ccf commit 83bb33c

20 files changed

+110
-91
lines changed
 

‎tests/src/core/testqgscomposerdd.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ class TestQgsComposerDD : public QObject
5353
void ddEvaluate(); //test setting/evaluating data defined value
5454

5555
private:
56-
QgsComposition* mComposition;
57-
QgsMapSettings mMapSettings;
56+
QgsComposition *mComposition;
57+
QgsMapSettings *mMapSettings;
5858
QgsVectorLayer* mVectorLayer;
5959
QgsComposerMap* mAtlasMap;
6060
QgsAtlasComposition* mAtlas;
@@ -66,6 +66,8 @@ void TestQgsComposerDD::initTestCase()
6666
QgsApplication::init();
6767
QgsApplication::initQgis();
6868

69+
mMapSettings = new QgsMapSettings();
70+
6971
//create maplayers from testdata and add to layer registry
7072
QFileInfo vectorFileInfo( QString( TEST_DATA_DIR ) + "/france_parts.shp" );
7173
mVectorLayer = new QgsVectorLayer( vectorFileInfo.filePath(),
@@ -79,15 +81,15 @@ void TestQgsComposerDD::initTestCase()
7981
QgsMapLayerRegistry::instance()->addMapLayers( QList<QgsMapLayer*>() << mVectorLayer );
8082

8183
//create composition with composer map
82-
mMapSettings.setLayers( QStringList() << mVectorLayer->id() );
83-
mMapSettings.setCrsTransformEnabled( true );
84-
mMapSettings.setMapUnits( QGis::Meters );
84+
mMapSettings->setLayers( QStringList() << mVectorLayer->id() );
85+
mMapSettings->setCrsTransformEnabled( true );
86+
mMapSettings->setMapUnits( QGis::Meters );
8587

8688
// select epsg:2154
8789
QgsCoordinateReferenceSystem crs;
8890
crs.createFromSrid( 2154 );
89-
mMapSettings.setDestinationCrs( crs );
90-
mComposition = new QgsComposition( mMapSettings );
91+
mMapSettings->setDestinationCrs( crs );
92+
mComposition = new QgsComposition( *mMapSettings );
9193
mComposition->setPaperSize( 297, 210 ); //A4 landscape
9294

9395
// fix the renderer, fill with green
@@ -114,6 +116,7 @@ void TestQgsComposerDD::initTestCase()
114116
void TestQgsComposerDD::cleanupTestCase()
115117
{
116118
delete mComposition;
119+
delete mMapSettings;
117120

118121
QString myReportFile = QDir::tempPath() + "/qgistest.html";
119122
QFile myFile( myReportFile );

‎tests/src/core/testqgscomposereffects.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class TestQgsComposerEffects : public QObject
3434
: mComposition( 0 )
3535
, mComposerRect1( 0 )
3636
, mComposerRect2( 0 )
37+
, mMapSettings( 0 )
3738
{}
3839

3940
private slots:
@@ -46,9 +47,9 @@ class TestQgsComposerEffects : public QObject
4647

4748
private:
4849
QgsComposition* mComposition;
49-
QgsComposerShape* mComposerRect1;
50-
QgsComposerShape* mComposerRect2;
51-
QgsMapSettings mMapSettings;
50+
QgsComposerShape *mComposerRect1;
51+
QgsComposerShape *mComposerRect2;
52+
QgsMapSettings *mMapSettings;
5253
QString mReport;
5354
};
5455

@@ -57,9 +58,11 @@ void TestQgsComposerEffects::initTestCase()
5758
QgsApplication::init();
5859
QgsApplication::initQgis();
5960

61+
mMapSettings = new QgsMapSettings();
62+
6063
//create composition with two rectangles
6164

62-
mComposition = new QgsComposition( mMapSettings );
65+
mComposition = new QgsComposition( *mMapSettings );
6366
mComposition->setPaperSize( 297, 210 ); //A4 landscape
6467
mComposerRect1 = new QgsComposerShape( 20, 20, 150, 100, mComposition );
6568
mComposerRect1->setShapeType( QgsComposerShape::Rectangle );
@@ -76,6 +79,7 @@ void TestQgsComposerEffects::initTestCase()
7679
void TestQgsComposerEffects::cleanupTestCase()
7780
{
7881
delete mComposition;
82+
delete mMapSettings;
7983

8084
QString myReportFile = QDir::tempPath() + "/qgistest.html";
8185
QFile myFile( myReportFile );

‎tests/src/core/testqgscomposergroup.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#include "qgscomposerlabel.h"
2020
#include "qgscomposition.h"
2121
#include "qgscompositionchecker.h"
22+
#include "qgsapplication.h"
23+
2224
#include <QObject>
2325
#include <QtTest/QtTest>
2426

@@ -45,8 +47,8 @@ class TestQgsComposerGroup : public QObject
4547
void undoRedo(); //test that group/ungroup undo/redo commands don't crash
4648

4749
private:
48-
QgsComposition* mComposition;
49-
QgsMapSettings mMapSettings;
50+
QgsComposition *mComposition;
51+
QgsMapSettings *mMapSettings;
5052
QgsComposerLabel* mItem1;
5153
QgsComposerLabel* mItem2;
5254
QgsComposerItemGroup* mGroup;
@@ -55,7 +57,11 @@ class TestQgsComposerGroup : public QObject
5557

5658
void TestQgsComposerGroup::initTestCase()
5759
{
58-
mComposition = new QgsComposition( mMapSettings );
60+
QgsApplication::init();
61+
QgsApplication::initQgis();
62+
63+
mMapSettings = new QgsMapSettings();
64+
mComposition = new QgsComposition( *mMapSettings );
5965
mComposition->setPaperSize( 297, 210 ); //A4 landscape
6066

6167
//create some items
@@ -72,6 +78,7 @@ void TestQgsComposerGroup::initTestCase()
7278
void TestQgsComposerGroup::cleanupTestCase()
7379
{
7480
delete mComposition;
81+
delete mMapSettings;
7582

7683
QString myReportFile = QDir::tempPath() + "/qgistest.html";
7784
QFile myFile( myReportFile );

‎tests/src/core/testqgscomposerhtml.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,15 @@ class TestQgsComposerHtml : public QObject
4444
void tableMultiFrame(); //tests multiframe capabilities of composer html
4545
void htmlMultiFrameSmartBreak(); //tests smart page breaks in html multi frame
4646
private:
47-
QgsComposition* mComposition;
48-
QgsMapSettings mMapSettings;
47+
QgsComposition *mComposition;
48+
QgsMapSettings *mMapSettings;
4949
QString mReport;
5050
QFont mTestFont;
5151
};
5252

5353
TestQgsComposerHtml::TestQgsComposerHtml()
54-
: mComposition( NULL )
54+
: mComposition( 0 )
55+
, mMapSettings( 0 )
5556
{
5657

5758
}
@@ -61,7 +62,8 @@ void TestQgsComposerHtml::initTestCase()
6162
QgsApplication::init();
6263
QgsApplication::initQgis();
6364

64-
mComposition = new QgsComposition( mMapSettings );
65+
mMapSettings = new QgsMapSettings();
66+
mComposition = new QgsComposition( *mMapSettings );
6567
mComposition->setPaperSize( 297, 210 ); //A4 landscape
6668

6769
mReport = "<h1>Composer HTML Tests</h1>\n";
@@ -73,6 +75,7 @@ void TestQgsComposerHtml::initTestCase()
7375
void TestQgsComposerHtml::cleanupTestCase()
7476
{
7577
delete mComposition;
78+
delete mMapSettings;
7679

7780
QString myReportFile = QDir::tempPath() + "/qgistest.html";
7881
QFile myFile( myReportFile );

‎tests/src/core/testqgscomposerlabel.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class TestQgsComposerLabel : public QObject
3434
TestQgsComposerLabel()
3535
: mComposition( 0 )
3636
, mComposerLabel( 0 )
37+
, mMapSettings( 0 )
3738
, mVectorLayer( 0 )
3839
{}
3940

@@ -55,7 +56,7 @@ class TestQgsComposerLabel : public QObject
5556
private:
5657
QgsComposition* mComposition;
5758
QgsComposerLabel* mComposerLabel;
58-
QgsMapSettings mMapSettings;
59+
QgsMapSettings *mMapSettings;
5960
QgsVectorLayer* mVectorLayer;
6061
};
6162

@@ -64,6 +65,8 @@ void TestQgsComposerLabel::initTestCase()
6465
QgsApplication::init();
6566
QgsApplication::initQgis();
6667

68+
mMapSettings = new QgsMapSettings();
69+
6770
//create maplayers from testdata and add to layer registry
6871
QFileInfo vectorFileInfo( QString( TEST_DATA_DIR ) + "/" + "france_parts.shp" );
6972
mVectorLayer = new QgsVectorLayer( vectorFileInfo.filePath(),
@@ -72,9 +75,9 @@ void TestQgsComposerLabel::initTestCase()
7275
QgsMapLayerRegistry::instance()->addMapLayers( QList<QgsMapLayer*>() << mVectorLayer );
7376

7477
//create composition with composer map
75-
mMapSettings.setLayers( QStringList() << mVectorLayer->id() );
76-
mMapSettings.setCrsTransformEnabled( false );
77-
mComposition = new QgsComposition( mMapSettings );
78+
mMapSettings->setLayers( QStringList() << mVectorLayer->id() );
79+
mMapSettings->setCrsTransformEnabled( false );
80+
mComposition = new QgsComposition( *mMapSettings );
7881
mComposition->setPaperSize( 297, 210 ); //A4 landscape
7982

8083
mComposerLabel = new QgsComposerLabel( mComposition );
@@ -86,6 +89,7 @@ void TestQgsComposerLabel::initTestCase()
8689
void TestQgsComposerLabel::cleanupTestCase()
8790
{
8891
delete mComposition;
92+
delete mMapSettings;
8993

9094
QgsApplication::exitQgis();
9195
}

‎tests/src/core/testqgscomposermap.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ class TestQgsComposerMap : public QObject
4848
void mapPolygonVertices(); // test mapPolygon function with no map rotation
4949

5050
private:
51-
QgsComposition* mComposition;
52-
QgsComposerMap* mComposerMap;
53-
QgsMapSettings mMapSettings;
51+
QgsComposition *mComposition;
52+
QgsComposerMap *mComposerMap;
53+
QgsMapSettings *mMapSettings;
5454
QgsRasterLayer* mRasterLayer;
5555
QString mReport;
5656
};
@@ -60,6 +60,8 @@ void TestQgsComposerMap::initTestCase()
6060
QgsApplication::init();
6161
QgsApplication::initQgis();
6262

63+
mMapSettings = new QgsMapSettings();
64+
6365
//create maplayers from testdata and add to layer registry
6466
QFileInfo rasterFileInfo( QString( TEST_DATA_DIR ) + "/landsat.tif" );
6567
mRasterLayer = new QgsRasterLayer( rasterFileInfo.filePath(),
@@ -70,9 +72,9 @@ void TestQgsComposerMap::initTestCase()
7072
QgsMapLayerRegistry::instance()->addMapLayers( QList<QgsMapLayer*>() << mRasterLayer );
7173

7274
//create composition with composer map
73-
mMapSettings.setLayers( QStringList() << mRasterLayer->id() );
74-
mMapSettings.setCrsTransformEnabled( false );
75-
mComposition = new QgsComposition( mMapSettings );
75+
mMapSettings->setLayers( QStringList() << mRasterLayer->id() );
76+
mMapSettings->setCrsTransformEnabled( false );
77+
mComposition = new QgsComposition( *mMapSettings );
7678
mComposition->setPaperSize( 297, 210 ); //A4 landscape
7779
mComposerMap = new QgsComposerMap( mComposition, 20, 20, 200, 100 );
7880
mComposerMap->setFrameEnabled( true );
@@ -84,6 +86,7 @@ void TestQgsComposerMap::initTestCase()
8486
void TestQgsComposerMap::cleanupTestCase()
8587
{
8688
delete mComposition;
89+
delete mMapSettings;
8790

8891
QString myReportFile = QDir::tempPath() + "/qgistest.html";
8992
QFile myFile( myReportFile );

‎tests/src/core/testqgscomposermapgrid.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ class TestQgsComposerMapGrid : public QObject
3232

3333
public:
3434
TestQgsComposerMapGrid();
35-
~TestQgsComposerMapGrid();
3635

3736
private slots:
3837
void initTestCase();// will be called before the first testfunction is executed.
@@ -76,18 +75,15 @@ TestQgsComposerMapGrid::TestQgsComposerMapGrid()
7675
mMapSettings = new QgsMapSettings();
7776
}
7877

79-
TestQgsComposerMapGrid::~TestQgsComposerMapGrid()
80-
{
81-
delete mMapSettings;
82-
}
83-
8478
void TestQgsComposerMapGrid::initTestCase()
8579
{
8680
mReport = "<h1>Composer Map Grid Tests</h1>\n";
8781
}
8882

8983
void TestQgsComposerMapGrid::cleanupTestCase()
9084
{
85+
delete mMapSettings;
86+
9187
QString myReportFile = QDir::tempPath() + "/qgistest.html";
9288
QFile myFile( myReportFile );
9389
if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) )

‎tests/src/core/testqgscomposermapoverview.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class TestQgsComposerMapOverview : public QObject
5454
private:
5555
QgsComposition* mComposition;
5656
QgsComposerMap* mComposerMap;
57-
QgsMapSettings mMapSettings;
57+
QgsMapSettings *mMapSettings;
5858
QgsRasterLayer* mRasterLayer;
5959
QString mReport;
6060
};
@@ -64,6 +64,8 @@ void TestQgsComposerMapOverview::initTestCase()
6464
QgsApplication::init();
6565
QgsApplication::initQgis();
6666

67+
mMapSettings = new QgsMapSettings();
68+
6769
//create maplayers from testdata and add to layer registry
6870
QFileInfo rasterFileInfo( QString( TEST_DATA_DIR ) + "/rgb256x256.png" );
6971
mRasterLayer = new QgsRasterLayer( rasterFileInfo.filePath(),
@@ -74,9 +76,9 @@ void TestQgsComposerMapOverview::initTestCase()
7476
QgsMapLayerRegistry::instance()->addMapLayers( QList<QgsMapLayer*>() << mRasterLayer );
7577

7678
//create composition with composer map
77-
mMapSettings.setLayers( QStringList() << mRasterLayer->id() );
78-
mMapSettings.setCrsTransformEnabled( false );
79-
mComposition = new QgsComposition( mMapSettings );
79+
mMapSettings->setLayers( QStringList() << mRasterLayer->id() );
80+
mMapSettings->setCrsTransformEnabled( false );
81+
mComposition = new QgsComposition( *mMapSettings );
8082
mComposition->setPaperSize( 297, 210 ); //A4 landscape
8183
mComposerMap = new QgsComposerMap( mComposition, 20, 20, 200, 100 );
8284
mComposerMap->setFrameEnabled( true );
@@ -88,6 +90,7 @@ void TestQgsComposerMapOverview::initTestCase()
8890
void TestQgsComposerMapOverview::cleanupTestCase()
8991
{
9092
delete mComposition;
93+
delete mMapSettings;
9194

9295
QString myReportFile = QDir::tempPath() + "/qgistest.html";
9396
QFile myFile( myReportFile );

‎tests/src/core/testqgscomposermodel.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,26 +62,28 @@ class TestQgsComposerModel : public QObject
6262
void reorderToBottomWithRemoved(); //test reordering to bottom with removed items
6363

6464
private:
65-
QgsComposition* mComposition;
66-
QgsComposerLabel* mItem1;
67-
QgsComposerLabel* mItem2;
68-
QgsComposerLabel* mItem3;
65+
QgsComposition *mComposition;
66+
QgsMapSettings *mMapSettings;
67+
QgsComposerLabel *mItem1;
68+
QgsComposerLabel *mItem2;
69+
QgsComposerLabel *mItem3;
6970
};
7071

7172
void TestQgsComposerModel::initTestCase()
7273
{
7374
QgsApplication::init();
7475
QgsApplication::initQgis();
7576

76-
QgsMapSettings mapSettings;
77-
mComposition = new QgsComposition( mapSettings );
77+
mMapSettings = new QgsMapSettings();
78+
mComposition = new QgsComposition( *mMapSettings );
7879

7980
mComposition->setPaperSize( 297, 210 ); //A4 landscape
8081
}
8182

8283
void TestQgsComposerModel::cleanupTestCase()
8384
{
8485
delete mComposition;
86+
delete mMapSettings;
8587
}
8688

8789
void TestQgsComposerModel::init()

‎tests/src/core/testqgscomposermultiframe.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,24 @@ class TestQgsComposerMultiFrame : public QObject
4444
void undoRedoRemovedFrame(); //test that undo doesn't crash with removed frames
4545

4646
private:
47-
QgsComposition* mComposition;
47+
QgsComposition *mComposition;
48+
QgsMapSettings *mMapSettings;
4849
QString mReport;
4950
};
5051

5152
TestQgsComposerMultiFrame::TestQgsComposerMultiFrame()
52-
: mComposition( NULL )
53+
: mComposition( 0 )
54+
, mMapSettings( 0 )
5355
{
54-
5556
}
5657

5758
void TestQgsComposerMultiFrame::initTestCase()
5859
{
5960
QgsApplication::init();
6061
QgsApplication::initQgis();
6162

62-
QgsMapSettings mapSettings;
63-
mComposition = new QgsComposition( mapSettings );
63+
mMapSettings = new QgsMapSettings();
64+
mComposition = new QgsComposition( *mMapSettings );
6465
mComposition->setPaperSize( 297, 210 ); //A4 landscape
6566

6667
mReport = "<h1>Composer MultiFrame Tests</h1>\n";
@@ -69,6 +70,7 @@ void TestQgsComposerMultiFrame::initTestCase()
6970
void TestQgsComposerMultiFrame::cleanupTestCase()
7071
{
7172
delete mComposition;
73+
delete mMapSettings;
7274

7375
QString myReportFile = QDir::tempPath() + "/qgistest.html";
7476
QFile myFile( myReportFile );

‎tests/src/core/testqgscomposerobject.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class TestQgsComposerObject : public QObject
3232
public:
3333
TestQgsComposerObject()
3434
: mComposition( 0 )
35+
, mMapSettings( 0 )
3536
{
3637
}
3738

@@ -50,6 +51,7 @@ class TestQgsComposerObject : public QObject
5051
private:
5152
bool renderCheck( QString testName, QImage &image, int mismatchCount = 0 );
5253
QgsComposition *mComposition;
54+
QgsMapSettings *mMapSettings;
5355
QString mReport;
5456

5557
};
@@ -59,8 +61,8 @@ void TestQgsComposerObject::initTestCase()
5961
QgsApplication::init();
6062
QgsApplication::initQgis();
6163

62-
QgsMapSettings mapSettings;
63-
mComposition = new QgsComposition( mapSettings );
64+
mMapSettings = new QgsMapSettings();
65+
mComposition = new QgsComposition( *mMapSettings );
6466
mComposition->setPaperSize( 297, 210 ); //A4 landscape
6567

6668
mReport = "<h1>Composer Object Tests</h1>\n";
@@ -69,6 +71,7 @@ void TestQgsComposerObject::initTestCase()
6971
void TestQgsComposerObject::cleanupTestCase()
7072
{
7173
delete mComposition;
74+
delete mMapSettings;
7275

7376
QString myReportFile = QDir::tempPath() + "/qgistest.html";
7477
QFile myFile( myReportFile );

‎tests/src/core/testqgscomposerpaper.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class TestQgsComposerPaper : public QObject
5959
QgsMarkerLineSymbolLayerV2* mMarkerLine;
6060
QgsFillSymbolV2* mFillSymbol;
6161
QgsFillSymbolV2* mMarkerLineSymbol;
62-
QgsMapSettings mMapSettings;
62+
QgsMapSettings *mMapSettings;
6363
// QgsSingleSymbolRendererV2* mSymbolRenderer;
6464

6565
};
@@ -70,7 +70,8 @@ void TestQgsComposerPaper::initTestCase()
7070
QgsApplication::initQgis();
7171

7272
//create empty composition
73-
mComposition = new QgsComposition( mMapSettings );
73+
mMapSettings = new QgsMapSettings();
74+
mComposition = new QgsComposition( *mMapSettings );
7475
mComposition->setPaperSize( 297, 210 ); //A4 landscape
7576

7677
//setup simple fill
@@ -89,6 +90,7 @@ void TestQgsComposerPaper::initTestCase()
8990
void TestQgsComposerPaper::cleanupTestCase()
9091
{
9192
delete mComposition;
93+
delete mMapSettings;
9294

9395
QString myReportFile = QDir::tempPath() + "/qgistest.html";
9496
QFile myFile( myReportFile );

‎tests/src/core/testqgscomposerpicture.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class TestQgsComposerPicture : public QObject
3030

3131
public:
3232
TestQgsComposerPicture();
33-
~TestQgsComposerPicture();
3433

3534
private slots:
3635
void initTestCase();// will be called before the first testfunction is executed.
@@ -77,11 +76,6 @@ TestQgsComposerPicture::TestQgsComposerPicture()
7776

7877
}
7978

80-
TestQgsComposerPicture::~TestQgsComposerPicture()
81-
{
82-
delete mMapSettings;
83-
}
84-
8579
void TestQgsComposerPicture::initTestCase()
8680
{
8781
QgsApplication::init();
@@ -106,6 +100,7 @@ void TestQgsComposerPicture::initTestCase()
106100
void TestQgsComposerPicture::cleanupTestCase()
107101
{
108102
delete mComposition;
103+
delete mMapSettings;
109104

110105
QString myReportFile = QDir::tempPath() + "/qgistest.html";
111106
QFile myFile( myReportFile );

‎tests/src/core/testqgscomposerrotation.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ class TestQgsComposerRotation : public QObject
4545
, mRasterLayer( 0 )
4646
{}
4747

48-
~TestQgsComposerRotation();
49-
5048
private slots:
5149
void initTestCase();// will be called before the first testfunction is executed.
5250
void cleanupTestCase();// will be called after the last testfunction was executed.
@@ -73,11 +71,6 @@ class TestQgsComposerRotation : public QObject
7371
QString mReport;
7472
};
7573

76-
TestQgsComposerRotation::~TestQgsComposerRotation()
77-
{
78-
delete mMapSettings;
79-
}
80-
8174
void TestQgsComposerRotation::initTestCase()
8275
{
8376
QgsApplication::init();
@@ -123,6 +116,7 @@ void TestQgsComposerRotation::cleanupTestCase()
123116
delete mComposerMap;
124117
}
125118
delete mComposition;
119+
delete mMapSettings;
126120

127121
QString myReportFile = QDir::tempPath() + "/qgistest.html";
128122
QFile myFile( myReportFile );

‎tests/src/core/testqgscomposerscalebar.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@ class TestQgsComposerScaleBar : public QObject
4141
, mMapSettings( 0 )
4242
{}
4343

44-
~TestQgsComposerScaleBar()
45-
{
46-
delete mMapSettings;
47-
}
48-
4944
private slots:
5045
void initTestCase();// will be called before the first testfunction is executed.
5146
void cleanupTestCase();// will be called after the last testfunction was executed.
@@ -119,6 +114,7 @@ void TestQgsComposerScaleBar::initTestCase()
119114
void TestQgsComposerScaleBar::cleanupTestCase()
120115
{
121116
delete mComposition;
117+
delete mMapSettings;
122118

123119
QString myReportFile = QDir::tempPath() + "/qgistest.html";
124120
QFile myFile( myReportFile );

‎tests/src/core/testqgscomposershapes.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class TestQgsComposerShapes : public QObject
5454
private:
5555
QgsComposition* mComposition;
5656
QgsComposerShape* mComposerShape;
57-
QgsMapSettings mMapSettings;
57+
QgsMapSettings *mMapSettings;
5858
QgsSimpleFillSymbolLayerV2* mSimpleFill;
5959
QgsFillSymbolV2* mFillSymbol;
6060
QString mReport;
@@ -65,8 +65,10 @@ void TestQgsComposerShapes::initTestCase()
6565
QgsApplication::init();
6666
QgsApplication::initQgis();
6767

68+
mMapSettings = new QgsMapSettings();
69+
6870
//create composition with two rectangles
69-
mComposition = new QgsComposition( mMapSettings );
71+
mComposition = new QgsComposition( *mMapSettings );
7072
mComposition->setPaperSize( 297, 210 ); //A4 landscape
7173
mComposerShape = new QgsComposerShape( 20, 20, 150, 100, mComposition );
7274
mComposerShape->setBackgroundColor( QColor::fromRgb( 255, 150, 0 ) );
@@ -83,6 +85,7 @@ void TestQgsComposerShapes::initTestCase()
8385
void TestQgsComposerShapes::cleanupTestCase()
8486
{
8587
delete mComposition;
88+
delete mMapSettings;
8689

8790
QString myReportFile = QDir::tempPath() + "/qgistest.html";
8891
QFile myFile( myReportFile );

‎tests/src/core/testqgscomposertable.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ class TestQgsComposerTable : public QObject
4141
, mVectorLayer( 0 )
4242
, mComposerAttributeTable( 0 )
4343
{}
44-
~TestQgsComposerTable()
45-
{
46-
delete mMapSettings;
47-
}
4844

4945
private slots:
5046
void initTestCase();// will be called before the first testfunction is executed.
@@ -109,6 +105,7 @@ void TestQgsComposerTable::initTestCase()
109105
void TestQgsComposerTable::cleanupTestCase()
110106
{
111107
delete mComposition;
108+
delete mMapSettings;
112109

113110
QgsApplication::exitQgis();
114111
}

‎tests/src/core/testqgscomposertablev2.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ void TestQgsComposerTableV2::initTestCase()
105105

106106
void TestQgsComposerTableV2::cleanupTestCase()
107107
{
108+
delete mMapSettings;
109+
108110
QString myReportFile = QDir::tempPath() + "/qgistest.html";
109111
QFile myFile( myReportFile );
110112
if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) )

‎tests/src/core/testqgscomposerutils.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class TestQgsComposerUtils : public QObject
3030
Q_OBJECT
3131
public:
3232
TestQgsComposerUtils();
33-
~TestQgsComposerUtils();
3433

3534
private slots:
3635
void initTestCase();// will be called before the first testfunction is executed.
@@ -71,21 +70,18 @@ class TestQgsComposerUtils : public QObject
7170
};
7271

7372
TestQgsComposerUtils::TestQgsComposerUtils()
74-
: mComposition( NULL )
73+
: mComposition( 0 )
74+
, mMapSettings( 0 )
7575
{
76-
QgsApplication::init();
77-
QgsApplication::initQgis(); //for access to test font
78-
79-
mMapSettings = new QgsMapSettings();
8076
}
8177

82-
TestQgsComposerUtils::~TestQgsComposerUtils()
83-
{
84-
delete mMapSettings;
85-
}
8678

8779
void TestQgsComposerUtils::initTestCase()
8880
{
81+
QgsApplication::init();
82+
QgsApplication::initQgis(); //for access to test font
83+
84+
mMapSettings = new QgsMapSettings();
8985
mComposition = new QgsComposition( *mMapSettings );
9086
mComposition->setPaperSize( 297, 210 ); //A4 landscape
9187

@@ -100,6 +96,7 @@ void TestQgsComposerUtils::initTestCase()
10096
void TestQgsComposerUtils::cleanupTestCase()
10197
{
10298
delete mComposition;
99+
delete mMapSettings;
103100

104101
QgsApplication::exitQgis();
105102

‎tests/src/core/testqgscomposition.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,13 @@ class TestQgsComposition : public QObject
4646

4747
private:
4848
QgsComposition *mComposition;
49+
QgsMapSettings *mMapSettings;
4950
QString mReport;
5051
};
5152

5253
TestQgsComposition::TestQgsComposition()
5354
: mComposition( 0 )
55+
, mMapSettings( 0 )
5456
{
5557
}
5658

@@ -59,12 +61,12 @@ void TestQgsComposition::initTestCase()
5961
QgsApplication::init();
6062
QgsApplication::initQgis();
6163

62-
QgsMapSettings mapSettings;
64+
mMapSettings = new QgsMapSettings();
6365

6466
//create composition
65-
mapSettings.setCrsTransformEnabled( true );
66-
mapSettings.setMapUnits( QGis::Meters );
67-
mComposition = new QgsComposition( mapSettings );
67+
mMapSettings->setCrsTransformEnabled( true );
68+
mMapSettings->setMapUnits( QGis::Meters );
69+
mComposition = new QgsComposition( *mMapSettings );
6870
mComposition->setPaperSize( 297, 210 ); //A4 landscape
6971
mComposition->setNumPages( 3 );
7072

@@ -75,6 +77,7 @@ void TestQgsComposition::initTestCase()
7577
void TestQgsComposition::cleanupTestCase()
7678
{
7779
delete mComposition;
80+
delete mMapSettings;
7881

7982
QString myReportFile = QDir::tempPath() + "/qgistest.html";
8083
QFile myFile( myReportFile );

0 commit comments

Comments
 (0)
Please sign in to comment.