Skip to content

Commit d13fb25

Browse files
committedNov 14, 2011
Fix problem with analyzer test
1 parent 2b8487b commit d13fb25

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed
 

‎src/analysis/vector/qgsgeometryanalyzer.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,14 @@ bool QgsGeometryAnalyzer::centroids( QgsVectorLayer* layer, const QString& shape
149149
{
150150
if ( !layer )
151151
{
152+
QgsDebugMsg( "No layer passed to centroids" );
152153
return false;
153154
}
154155

155156
QgsVectorDataProvider* dp = layer->dataProvider();
156157
if ( !dp )
157158
{
159+
QgsDebugMsg( "No data provider for layer passed to centroids" );
158160
return false;
159161
}
160162

‎src/core/qgsapplication.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ class CORE_EXPORT QgsApplication: public QApplication
3434
virtual ~QgsApplication();
3535

3636
/** This method initialises paths etc for QGIS. Called by the ctor or call it manually
37-
when your app does not extend the QApplication class. */
37+
when your app does not extend the QApplication class.
38+
@note you will probably want to call initQgis too to load the providers in
39+
the above case.
40+
*/
3841
static void init( QString customConfigPath = QString() );
3942

4043
//! Watch for QFileOpenEvent.

‎tests/src/analysis/testqgsvectoranalyzer.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -51,28 +51,30 @@ void TestQgsVectorAnalyzer::initTestCase()
5151
//
5252
// init QGIS's paths - true means that all path will be inited from prefix
5353
QString qgisPath = QCoreApplication::applicationDirPath ();
54-
QgsApplication::setPrefixPath(INSTALL_PREFIX, true);
54+
QgsApplication::init( INSTALL_PREFIX );
55+
QgsApplication::initQgis( );
5556
QgsApplication::showSettings();
5657
// Instantiate the plugin directory so that providers are loaded
5758
QgsProviderRegistry::instance(QgsApplication::pluginPath());
5859

5960
//create some objects that will be used in all tests...
6061
//create a map layer that will be used in all tests...
61-
QString myFileName (TEST_DATA_DIR); //defined in CmakeLists.txt
62+
QString myBaseFileName (TEST_DATA_DIR); //defined in CmakeLists.txt
6263
QString myEndName = "lines.shp";
63-
myFileName = myFileName + QDir::separator() + myEndName;
64+
QString myFileName = myBaseFileName + QDir::separator() + myEndName;
65+
qDebug() << myFileName;
6466
QFileInfo myLineInfo ( myFileName );
6567
mpLineLayer = new QgsVectorLayer ( myLineInfo.filePath(),
6668
myLineInfo.completeBaseName(), "ogr" );
6769

6870
myEndName = "polys.shp";
69-
myFileName = myFileName + QDir::separator() + myEndName;
71+
myFileName = myBaseFileName + QDir::separator() + myEndName;
7072
QFileInfo myPolyInfo ( myFileName );
7173
mpPolyLayer = new QgsVectorLayer ( myPolyInfo.filePath(),
7274
myPolyInfo.completeBaseName(), "ogr" );
7375

7476
myEndName = "points.shp";
75-
myFileName = myFileName + QDir::separator() + myEndName;
77+
myFileName = myBaseFileName + QDir::separator() + myEndName;
7678
QFileInfo myPointInfo ( myFileName );
7779
mpPointLayer = new QgsVectorLayer ( myPointInfo.filePath(),
7880
myPointInfo.completeBaseName(), "ogr" );

0 commit comments

Comments
 (0)
Please sign in to comment.