From d13fb2586b843211830b15b78719f94b652d400a Mon Sep 17 00:00:00 2001 From: Tim Sutton Date: Mon, 14 Nov 2011 15:36:55 +0200 Subject: [PATCH] Fix problem with analyzer test --- src/analysis/vector/qgsgeometryanalyzer.cpp | 2 ++ src/core/qgsapplication.h | 5 ++++- tests/src/analysis/testqgsvectoranalyzer.cpp | 12 +++++++----- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/analysis/vector/qgsgeometryanalyzer.cpp b/src/analysis/vector/qgsgeometryanalyzer.cpp index 98fd740738d..3bb80e65a4e 100644 --- a/src/analysis/vector/qgsgeometryanalyzer.cpp +++ b/src/analysis/vector/qgsgeometryanalyzer.cpp @@ -149,12 +149,14 @@ bool QgsGeometryAnalyzer::centroids( QgsVectorLayer* layer, const QString& shape { if ( !layer ) { + QgsDebugMsg( "No layer passed to centroids" ); return false; } QgsVectorDataProvider* dp = layer->dataProvider(); if ( !dp ) { + QgsDebugMsg( "No data provider for layer passed to centroids" ); return false; } diff --git a/src/core/qgsapplication.h b/src/core/qgsapplication.h index 272ddfd8362..6da4117f966 100644 --- a/src/core/qgsapplication.h +++ b/src/core/qgsapplication.h @@ -34,7 +34,10 @@ class CORE_EXPORT QgsApplication: public QApplication virtual ~QgsApplication(); /** This method initialises paths etc for QGIS. Called by the ctor or call it manually - when your app does not extend the QApplication class. */ + when your app does not extend the QApplication class. + @note you will probably want to call initQgis too to load the providers in + the above case. + */ static void init( QString customConfigPath = QString() ); //! Watch for QFileOpenEvent. diff --git a/tests/src/analysis/testqgsvectoranalyzer.cpp b/tests/src/analysis/testqgsvectoranalyzer.cpp index cf2e7c8947b..1719b3c6789 100644 --- a/tests/src/analysis/testqgsvectoranalyzer.cpp +++ b/tests/src/analysis/testqgsvectoranalyzer.cpp @@ -51,28 +51,30 @@ void TestQgsVectorAnalyzer::initTestCase() // // init QGIS's paths - true means that all path will be inited from prefix QString qgisPath = QCoreApplication::applicationDirPath (); - QgsApplication::setPrefixPath(INSTALL_PREFIX, true); + QgsApplication::init( INSTALL_PREFIX ); + QgsApplication::initQgis( ); QgsApplication::showSettings(); // Instantiate the plugin directory so that providers are loaded QgsProviderRegistry::instance(QgsApplication::pluginPath()); //create some objects that will be used in all tests... //create a map layer that will be used in all tests... - QString myFileName (TEST_DATA_DIR); //defined in CmakeLists.txt + QString myBaseFileName (TEST_DATA_DIR); //defined in CmakeLists.txt QString myEndName = "lines.shp"; - myFileName = myFileName + QDir::separator() + myEndName; + QString myFileName = myBaseFileName + QDir::separator() + myEndName; + qDebug() << myFileName; QFileInfo myLineInfo ( myFileName ); mpLineLayer = new QgsVectorLayer ( myLineInfo.filePath(), myLineInfo.completeBaseName(), "ogr" ); myEndName = "polys.shp"; - myFileName = myFileName + QDir::separator() + myEndName; + myFileName = myBaseFileName + QDir::separator() + myEndName; QFileInfo myPolyInfo ( myFileName ); mpPolyLayer = new QgsVectorLayer ( myPolyInfo.filePath(), myPolyInfo.completeBaseName(), "ogr" ); myEndName = "points.shp"; - myFileName = myFileName + QDir::separator() + myEndName; + myFileName = myBaseFileName + QDir::separator() + myEndName; QFileInfo myPointInfo ( myFileName ); mpPointLayer = new QgsVectorLayer ( myPointInfo.filePath(), myPointInfo.completeBaseName(), "ogr" );