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 committed Dec 5, 2011
1 parent a129207 commit 917f748
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/core/qgsproject.cpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -1336,7 +1336,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 @@ -1383,6 +1383,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 @@ -1428,14 +1433,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 917f748

Please sign in to comment.