File tree 2 files changed +22
-1
lines changed
2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -163,7 +163,8 @@ QString QgsPathResolver::writePath( const QString &src ) const
163
163
return src;
164
164
}
165
165
166
- QFileInfo srcFileInfo ( src );
166
+ // Strip "file://"
167
+ QFileInfo srcFileInfo ( src.startsWith ( QStringLiteral ( " file://" ) ) ? src.mid ( 7 ) : src );
167
168
QString srcPath = srcFileInfo.exists () ? srcFileInfo.canonicalFilePath () : src;
168
169
169
170
// if this is a VSIFILE, remove the VSI prefix and append to final result
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ class TestQgsProject : public QObject
41
41
void testProjectUnits ();
42
42
void variablesChanged ();
43
43
void testLayerFlags ();
44
+ void testLocalFiles ();
44
45
};
45
46
46
47
void TestQgsProject::init ()
@@ -386,6 +387,25 @@ void TestQgsProject::testLayerFlags()
386
387
QVERIFY ( !layer->flags ().testFlag ( QgsMapLayer::Removable ) );
387
388
}
388
389
390
+ void TestQgsProject::testLocalFiles ()
391
+ {
392
+ QTemporaryFile f;
393
+ QVERIFY ( f.open () );
394
+ f.close ();
395
+ QgsProject prj;
396
+ QFileInfo info ( f.fileName () );
397
+ prj.setFileName ( f.fileName () );
398
+ prj.write ();
399
+ QString shpPath = info.dir ().path () + ' /' + info.baseName () + " .shp" ;
400
+ QString layerPath = " file://" + shpPath;
401
+ QFile f2 ( shpPath );
402
+ QVERIFY ( f2.open ( QFile::ReadWrite ) );
403
+ f2.close ();
404
+ QgsPathResolver resolver ( f.fileName ( ) );
405
+ QCOMPARE ( resolver.writePath ( layerPath ), QString ( " ./" + info.baseName () + " .shp" ) ) ;
406
+
407
+ }
408
+
389
409
390
410
QGSTEST_MAIN ( TestQgsProject )
391
411
#include " testqgsproject.moc"
You can’t perform that action at this time.
0 commit comments