Skip to content

Commit

Permalink
Fix crash with relative file paths if projPath is not yet defined
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent authored and mach0 committed Dec 7, 2011
1 parent 5386cfc commit 4ddb938
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/core/qgsproject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1350,7 +1350,7 @@ void QgsProject::dumpProperties() const
// return the absolute path from a filename read from project file
QString QgsProject::readPath( QString src ) const
{
if ( readBoolEntry( "Paths", "/Absolute", true ) )
if ( readBoolEntry( "Paths", "/Absolute", false ) )
{
return src;
}
Expand Down Expand Up @@ -1395,6 +1395,11 @@ QString QgsProject::readPath( QString src ) const
QString srcPath = src;
QString projPath = fileName();

if ( projPath.isEmpty() )
{
return src;
}

#if defined(Q_OS_WIN)
srcPath.replace( "\\", "/" );
projPath.replace( "\\", "/" );
Expand Down Expand Up @@ -1440,14 +1445,19 @@ QString QgsProject::readPath( QString src ) const
// return the absolute or relative path to write it to the project file
QString QgsProject::writePath( QString src ) const
{
if ( readBoolEntry( "Paths", "/Absolute", true ) || src.isEmpty() )
if ( readBoolEntry( "Paths", "/Absolute", false ) || src.isEmpty() )
{
return src;
}

QString srcPath = src;
QString projPath = fileName();

if ( projPath.isEmpty() )
{
return src;
}

#if defined( Q_OS_WIN )
const Qt::CaseSensitivity cs = Qt::CaseInsensitive;

Expand Down

0 comments on commit 4ddb938

Please sign in to comment.