Skip to content

Commit

Permalink
Fix some race condition segfaults of tests on exit
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Nov 21, 2014
1 parent 78c5195 commit 95f6483
Show file tree
Hide file tree
Showing 43 changed files with 109 additions and 25 deletions.
2 changes: 1 addition & 1 deletion tests/src/analysis/testqgsvectoranalyzer.cpp
Expand Up @@ -78,7 +78,7 @@ void TestQgsVectorAnalyzer::initTestCase()
}
void TestQgsVectorAnalyzer::cleanupTestCase()
{

QgsApplication::exitQgis();
}
void TestQgsVectorAnalyzer::init()
{
Expand Down
7 changes: 6 additions & 1 deletion tests/src/analysis/testqgszonalstatistics.cpp
Expand Up @@ -28,7 +28,7 @@ class TestQgsZonalStatistics: public QObject
Q_OBJECT;
private slots:
void initTestCase();
void cleanupTestCase() {};
void cleanupTestCase();
void init() {};
void cleanup() {};

Expand Down Expand Up @@ -62,6 +62,11 @@ void TestQgsZonalStatistics::initTestCase()
mRasterPath = myTempPath + "edge_problem.asc";
}

void TestQgsZonalStatistics::cleanupTestCase()
{
QgsApplication::exitQgis();
}

void TestQgsZonalStatistics::testStatistics()
{
QgsZonalStatistics zs( mVectorLayer, mRasterPath, "", 1 );
Expand Down
1 change: 1 addition & 0 deletions tests/src/app/testqgisappclipboard.cpp
Expand Up @@ -63,6 +63,7 @@ void TestQgisAppClipboard::initTestCase()
//runs after all tests
void TestQgisAppClipboard::cleanupTestCase()
{
QgsApplication::exitQgis();
}

void TestQgisAppClipboard::copyPaste()
Expand Down
2 changes: 1 addition & 1 deletion tests/src/core/regression992.cpp
Expand Up @@ -105,7 +105,7 @@ void Regression992::cleanupTestCase()
//QDesktopServices::openUrl( "file:///" + myReportFile );
}

delete mpRasterLayer;
QgsApplication::exitQgis();
}

void Regression992::regression992()
Expand Down
6 changes: 6 additions & 0 deletions tests/src/core/testqgsapplication.cpp
Expand Up @@ -30,6 +30,7 @@ class TestQgsApplication: public QObject
void checkPaths();
void checkGdalSkip();
void initTestCase();
void cleanupTestCase();
private:
QString getQgisPath();
};
Expand All @@ -46,6 +47,11 @@ void TestQgsApplication::initTestCase()
qDebug( "%s", QgsApplication::showSettings().toUtf8().constData() );
};

void TestQgsApplication::cleanupTestCase()
{
QgsApplication::exitQgis();
}

void TestQgsApplication::checkPaths()
{
QString myPath = QgsApplication::authorsFilePath();
Expand Down
4 changes: 3 additions & 1 deletion tests/src/core/testqgsblendmodes.cpp
Expand Up @@ -112,7 +112,7 @@ void TestQgsBlendModes::initTestCase()
rasterFileInfo.completeBaseName() );
QgsMultiBandColorRenderer* rasterRenderer = new QgsMultiBandColorRenderer( mRasterLayer1->dataProvider(), 2, 3, 4 );
mRasterLayer1->setRenderer( rasterRenderer );
mRasterLayer2->setRenderer( rasterRenderer );
mRasterLayer2->setRenderer(( QgsRasterRenderer* ) rasterRenderer->clone() );
QgsMapLayerRegistry::instance()->addMapLayers(
QList<QgsMapLayer *>() << mRasterLayer1 );
QgsMapLayerRegistry::instance()->addMapLayers(
Expand All @@ -131,6 +131,8 @@ void TestQgsBlendModes::cleanupTestCase()
myQTextStream << mReport;
myFile.close();
}

QgsApplication::exitQgis();
}

void TestQgsBlendModes::vectorBlending()
Expand Down
2 changes: 1 addition & 1 deletion tests/src/core/testqgscomposerdd.cpp
Expand Up @@ -105,7 +105,6 @@ void TestQgsComposerDD::initTestCase()
void TestQgsComposerDD::cleanupTestCase()
{
delete mComposition;
delete mVectorLayer;

QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html";
QFile myFile( myReportFile );
Expand All @@ -115,6 +114,7 @@ void TestQgsComposerDD::cleanupTestCase()
myQTextStream << mReport;
myFile.close();
}
QgsApplication::exitQgis();
}

void TestQgsComposerDD::init()
Expand Down
2 changes: 2 additions & 0 deletions tests/src/core/testqgscomposereffects.cpp
Expand Up @@ -77,6 +77,8 @@ void TestQgsComposerEffects::cleanupTestCase()
myQTextStream << mReport;
myFile.close();
}

QgsApplication::exitQgis();
}

void TestQgsComposerEffects::init()
Expand Down
3 changes: 2 additions & 1 deletion tests/src/core/testqgscomposerlabel.cpp
Expand Up @@ -78,7 +78,8 @@ void TestQgsComposerLabel::initTestCase()
void TestQgsComposerLabel::cleanupTestCase()
{
delete mComposition;
delete mVectorLayer;

QgsApplication::exitQgis();
}

void TestQgsComposerLabel::init()
Expand Down
3 changes: 2 additions & 1 deletion tests/src/core/testqgscomposermap.cpp
Expand Up @@ -76,7 +76,6 @@ void TestQgsComposerMap::initTestCase()
void TestQgsComposerMap::cleanupTestCase()
{
delete mComposition;
delete mRasterLayer;

QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html";
QFile myFile( myReportFile );
Expand All @@ -86,6 +85,8 @@ void TestQgsComposerMap::cleanupTestCase()
myQTextStream << mReport;
myFile.close();
}

QgsApplication::exitQgis();
}

void TestQgsComposerMap::init()
Expand Down
2 changes: 2 additions & 0 deletions tests/src/core/testqgscomposermapgrid.cpp
Expand Up @@ -91,6 +91,8 @@ void TestQgsComposerMapGrid::cleanupTestCase()
myQTextStream << mReport;
myFile.close();
}

QgsApplication::exitQgis();
}

void TestQgsComposerMapGrid::init()
Expand Down
2 changes: 1 addition & 1 deletion tests/src/core/testqgscomposermapoverview.cpp
Expand Up @@ -80,7 +80,6 @@ void TestQgsComposerMapOverview::initTestCase()
void TestQgsComposerMapOverview::cleanupTestCase()
{
delete mComposition;
delete mRasterLayer;

QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html";
QFile myFile( myReportFile );
Expand All @@ -90,6 +89,7 @@ void TestQgsComposerMapOverview::cleanupTestCase()
myQTextStream << mReport;
myFile.close();
}
QgsApplication::exitQgis();
}

void TestQgsComposerMapOverview::init()
Expand Down
5 changes: 3 additions & 2 deletions tests/src/core/testqgscomposerrotation.cpp
Expand Up @@ -97,10 +97,9 @@ void TestQgsComposerRotation::initTestCase()

mReport = "<h1>Composer Rotation Tests</h1>\n";
}

void TestQgsComposerRotation::cleanupTestCase()
{
delete mComposition;

QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html";
QFile myFile( myReportFile );
if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) )
Expand All @@ -109,6 +108,8 @@ void TestQgsComposerRotation::cleanupTestCase()
myQTextStream << mReport;
myFile.close();
}

QgsApplication::exitQgis();
}

void TestQgsComposerRotation::init()
Expand Down
3 changes: 2 additions & 1 deletion tests/src/core/testqgscomposerscalebar.cpp
Expand Up @@ -101,7 +101,6 @@ void TestQgsComposerScaleBar::initTestCase()
void TestQgsComposerScaleBar::cleanupTestCase()
{
delete mComposition;
delete mRasterLayer;

QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html";
QFile myFile( myReportFile );
Expand All @@ -111,6 +110,8 @@ void TestQgsComposerScaleBar::cleanupTestCase()
myQTextStream << mReport;
myFile.close();
}

QgsApplication::exitQgis();
};

void TestQgsComposerScaleBar::init()
Expand Down
3 changes: 2 additions & 1 deletion tests/src/core/testqgscomposertable.cpp
Expand Up @@ -92,7 +92,8 @@ void TestQgsComposerTable::initTestCase()
void TestQgsComposerTable::cleanupTestCase()
{
delete mComposition;
delete mVectorLayer;

QgsApplication::exitQgis();
}

void TestQgsComposerTable::init()
Expand Down
2 changes: 2 additions & 0 deletions tests/src/core/testqgscomposerutils.cpp
Expand Up @@ -84,6 +84,8 @@ void TestQgsComposerUtils::initTestCase()

void TestQgsComposerUtils::cleanupTestCase()
{
QgsApplication::exitQgis();

delete mComposition;

QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html";
Expand Down
6 changes: 6 additions & 0 deletions tests/src/core/testqgscoordinatereferencesystem.cpp
Expand Up @@ -34,6 +34,7 @@ class TestQgsCoordinateReferenceSystem: public QObject
Q_OBJECT
private slots:
void initTestCase();
void cleanupTestCase();
void wktCtor();
void idCtor();
void copyCtor();
Expand Down Expand Up @@ -101,6 +102,11 @@ void TestQgsCoordinateReferenceSystem::initTestCase()

}

void TestQgsCoordinateReferenceSystem::cleanupTestCase()
{
QgsApplication::exitQgis();
}

void TestQgsCoordinateReferenceSystem::wktCtor()
{
QString myWkt = GEOWKT;
Expand Down
6 changes: 6 additions & 0 deletions tests/src/core/testqgscoordinatetransform.cpp
Expand Up @@ -25,6 +25,7 @@ class TestQgsCoordinateTransform: public QObject

private slots:
void initTestCase();
void cleanupTestCase();
void transformBoundingBox();

private:
Expand All @@ -39,6 +40,11 @@ void TestQgsCoordinateTransform::initTestCase()

}

void TestQgsCoordinateTransform::cleanupTestCase()
{
QgsApplication::exitQgis();
}

void TestQgsCoordinateTransform::transformBoundingBox()
{
//test transforming a bounding box which crosses the 180 degree longitude line
Expand Down
4 changes: 3 additions & 1 deletion tests/src/core/testqgsdataitem.cpp
Expand Up @@ -33,7 +33,7 @@ class TestQgsDataItem: public QObject

private slots:
void initTestCase();// will be called before the first testfunction is executed.
void cleanupTestCase();;// will be called after the last testfunction was executed.
void cleanupTestCase();// will be called after the last testfunction was executed.
void init() {};// will be called before each testfunction is executed.
void cleanup() {};// will be called after every testfunction.

Expand Down Expand Up @@ -75,6 +75,8 @@ void TestQgsDataItem::cleanupTestCase()
settings.setValue( "/qgis/scanItemsInBrowser2", mScanItemsSetting );
if ( mDirItem )
delete mDirItem;

QgsApplication::exitQgis();
}

bool TestQgsDataItem::isValidDirItem( QgsDirectoryItem *item )
Expand Down
5 changes: 1 addition & 4 deletions tests/src/core/testqgsdiagram.cpp
Expand Up @@ -109,6 +109,7 @@ class TestQgsDiagram: public QObject
// will be called after the last testfunction was executed.
void cleanupTestCase()
{
QgsApplication::exitQgis();
QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html";
QFile myFile( myReportFile );
if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) )
Expand All @@ -118,10 +119,6 @@ class TestQgsDiagram: public QObject
myFile.close();
//QDesktopServices::openUrl( "file:///" + myReportFile );
}

delete mComposerMap;
delete mComposition;
delete mPointsLayer;
}
void init() {};// will be called before each testfunction is executed.
void cleanup() {};// will be called after every testfunction.
Expand Down
1 change: 1 addition & 0 deletions tests/src/core/testqgsdiagramexpression.cpp
Expand Up @@ -114,6 +114,7 @@ class TestQgsDiagramExpression: public QObject
// will be called after the last testfunction was executed.
void cleanupTestCase()
{
QgsApplication::exitQgis();
QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html";
QFile myFile( myReportFile );
if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) )
Expand Down
6 changes: 6 additions & 0 deletions tests/src/core/testqgsdistancearea.cpp
Expand Up @@ -30,6 +30,7 @@ class TestQgsDistanceArea: public QObject
Q_OBJECT;
private slots:
void initTestCase();
void cleanupTestCase();
void basic();
void test_distances();
void unit_conversions();
Expand All @@ -46,6 +47,11 @@ void TestQgsDistanceArea::initTestCase()
QgsApplication::showSettings();
}

void TestQgsDistanceArea::cleanupTestCase()
{
QgsApplication::exitQgis();
}

void TestQgsDistanceArea::basic()
{
QgsPoint p1( 1.0, 3.0 ), p2( -2.0, -1.0 );
Expand Down
5 changes: 5 additions & 0 deletions tests/src/core/testqgsexpression.cpp
Expand Up @@ -59,6 +59,11 @@ class TestQgsExpression: public QObject
QgsApplication::showSettings();
}

void cleanupTestCase()
{
QgsApplication::exitQgis();
}

void parsing_data()
{
QTest::addColumn<QString>( "string" );
Expand Down
1 change: 1 addition & 0 deletions tests/src/core/testqgsgeometry.cpp
Expand Up @@ -320,6 +320,7 @@ void TestQgsGeometry::cleanupTestCase()
//QDesktopServices::openUrl( "file:///" + myReportFile );
}

QgsApplication::exitQgis();
}

// MK, Disabled 14.11.2014
Expand Down
2 changes: 2 additions & 0 deletions tests/src/core/testqgsgradients.cpp
Expand Up @@ -128,6 +128,8 @@ void TestQgsGradients::cleanupTestCase()
myQTextStream << mReport;
myFile.close();
}

QgsApplication::exitQgis();
}

void TestQgsGradients::gradientSymbol()
Expand Down
2 changes: 2 additions & 0 deletions tests/src/core/testqgsinvertedpolygonrenderer.cpp
Expand Up @@ -101,6 +101,8 @@ void TestQgsInvertedPolygon::cleanupTestCase()
myQTextStream << mReport;
myFile.close();
}

QgsApplication::exitQgis();
}

void TestQgsInvertedPolygon::singleSubRenderer()
Expand Down
7 changes: 6 additions & 1 deletion tests/src/core/testqgsmaplayer.cpp
Expand Up @@ -50,7 +50,7 @@ class TestQgsMapLayer: public QObject
Q_OBJECT;
private slots:
void initTestCase();// will be called before the first testfunction is executed.
void cleanupTestCase() {};// will be called after the last testfunction was executed.
void cleanupTestCase();// will be called after the last testfunction was executed.
void init() {};// will be called before each testfunction is executed.
void cleanup() {};// will be called after every testfunction.

Expand Down Expand Up @@ -80,6 +80,11 @@ void TestQgsMapLayer::initTestCase()
myMapFileInfo.completeBaseName(), "ogr" );
}

void TestQgsMapLayer::cleanupTestCase()
{
QgsApplication::exitQgis();
}

void TestQgsMapLayer::isValid()
{
QVERIFY( mpLayer->isValid() );
Expand Down
2 changes: 2 additions & 0 deletions tests/src/core/testqgsmaprenderer.cpp
Expand Up @@ -171,6 +171,8 @@ void TestQgsMapRenderer::initTestCase()

void TestQgsMapRenderer::cleanupTestCase()
{
QgsApplication::exitQgis();

QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html";
QFile myFile( myReportFile );
if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) )
Expand Down
1 change: 1 addition & 0 deletions tests/src/core/testqgsrasterfilewriter.cpp
Expand Up @@ -74,6 +74,7 @@ void TestQgsRasterFileWriter::initTestCase()
//runs after all tests
void TestQgsRasterFileWriter::cleanupTestCase()
{
QgsApplication::exitQgis();
QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html";
QFile myFile( myReportFile );
if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) )
Expand Down

0 comments on commit 95f6483

Please sign in to comment.