File tree 2 files changed +14
-1
lines changed
2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ QString QgsPathResolver::readPath( const QString &filename ) const
72
72
// from the filename.
73
73
74
74
QFileInfo pfi ( mBaseFileName );
75
- QString home = pfi.absoluteFilePath ();
75
+ QString home = pfi.absolutePath ();
76
76
if ( home.isEmpty () )
77
77
return vsiPrefix + src;
78
78
Original file line number Diff line number Diff line change @@ -108,6 +108,19 @@ void TestQgsProject::testPathResolver()
108
108
QCOMPARE ( resolverRel.readPath ( " ../file1.txt" ), QString ( " /home/file1.txt" ) );
109
109
QCOMPARE ( resolverRel.readPath ( " /home/qgis/file1.txt" ), QString ( " /home/qgis/file1.txt" ) );
110
110
111
+ // test older style relative path - file must exist for this to work
112
+ QTemporaryFile tmpFile;
113
+ tmpFile.open (); // fileName is not available until we open the file
114
+ QString tmpName = tmpFile.fileName ();
115
+ tmpFile.close ();
116
+ QgsPathResolver tempRel ( tmpName );
117
+ QFileInfo fi ( tmpName );
118
+ QFile testFile ( fi.path () + QStringLiteral ( " /file1.txt" ) );
119
+ testFile.open ( QIODevice::WriteOnly | QIODevice::Text );
120
+ testFile.close ();
121
+ QVERIFY ( QFile::exists ( fi.path () + QStringLiteral ( " /file1.txt" ) ) );
122
+ QCOMPARE ( tempRel.readPath ( " file1.txt" ), fi.path () + QStringLiteral ( " /file1.txt" ) );
123
+
111
124
QgsPathResolver resolverAbs;
112
125
QCOMPARE ( resolverAbs.writePath ( " /home/qgis/file1.txt" ), QString ( " /home/qgis/file1.txt" ) );
113
126
QCOMPARE ( resolverAbs.readPath ( " /home/qgis/file1.txt" ), QString ( " /home/qgis/file1.txt" ) );
You can’t perform that action at this time.
0 commit comments