Skip to content

Commit 917f748

Browse files
committed
Fix crash with relative file paths if projPath is not yet defined
1 parent a129207 commit 917f748

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/core/qgsproject.cpp

100755100644
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,7 +1336,7 @@ void QgsProject::dumpProperties() const
13361336
// return the absolute path from a filename read from project file
13371337
QString QgsProject::readPath( QString src ) const
13381338
{
1339-
if ( readBoolEntry( "Paths", "/Absolute", true ) )
1339+
if ( readBoolEntry( "Paths", "/Absolute", false ) )
13401340
{
13411341
return src;
13421342
}
@@ -1383,6 +1383,11 @@ QString QgsProject::readPath( QString src ) const
13831383
QString srcPath = src;
13841384
QString projPath = fileName();
13851385

1386+
if ( projPath.isEmpty() )
1387+
{
1388+
return src;
1389+
}
1390+
13861391
#if defined(Q_OS_WIN)
13871392
srcPath.replace( "\\", "/" );
13881393
projPath.replace( "\\", "/" );
@@ -1428,14 +1433,19 @@ QString QgsProject::readPath( QString src ) const
14281433
// return the absolute or relative path to write it to the project file
14291434
QString QgsProject::writePath( QString src ) const
14301435
{
1431-
if ( readBoolEntry( "Paths", "/Absolute", true ) || src.isEmpty() )
1436+
if ( readBoolEntry( "Paths", "/Absolute", false ) || src.isEmpty() )
14321437
{
14331438
return src;
14341439
}
14351440

14361441
QString srcPath = src;
14371442
QString projPath = fileName();
14381443

1444+
if ( projPath.isEmpty() )
1445+
{
1446+
return src;
1447+
}
1448+
14391449
#if defined( Q_OS_WIN )
14401450
const Qt::CaseSensitivity cs = Qt::CaseInsensitive;
14411451

0 commit comments

Comments
 (0)