Skip to content

Commit 4ddb938

Browse files
mhugentmach0
authored andcommitted
Fix crash with relative file paths if projPath is not yet defined
1 parent 5386cfc commit 4ddb938

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/core/qgsproject.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,7 +1350,7 @@ void QgsProject::dumpProperties() const
13501350
// return the absolute path from a filename read from project file
13511351
QString QgsProject::readPath( QString src ) const
13521352
{
1353-
if ( readBoolEntry( "Paths", "/Absolute", true ) )
1353+
if ( readBoolEntry( "Paths", "/Absolute", false ) )
13541354
{
13551355
return src;
13561356
}
@@ -1395,6 +1395,11 @@ QString QgsProject::readPath( QString src ) const
13951395
QString srcPath = src;
13961396
QString projPath = fileName();
13971397

1398+
if ( projPath.isEmpty() )
1399+
{
1400+
return src;
1401+
}
1402+
13981403
#if defined(Q_OS_WIN)
13991404
srcPath.replace( "\\", "/" );
14001405
projPath.replace( "\\", "/" );
@@ -1440,14 +1445,19 @@ QString QgsProject::readPath( QString src ) const
14401445
// return the absolute or relative path to write it to the project file
14411446
QString QgsProject::writePath( QString src ) const
14421447
{
1443-
if ( readBoolEntry( "Paths", "/Absolute", true ) || src.isEmpty() )
1448+
if ( readBoolEntry( "Paths", "/Absolute", false ) || src.isEmpty() )
14441449
{
14451450
return src;
14461451
}
14471452

14481453
QString srcPath = src;
14491454
QString projPath = fileName();
14501455

1456+
if ( projPath.isEmpty() )
1457+
{
1458+
return src;
1459+
}
1460+
14511461
#if defined( Q_OS_WIN )
14521462
const Qt::CaseSensitivity cs = Qt::CaseInsensitive;
14531463

0 commit comments

Comments
 (0)