Skip to content

Commit

Permalink
svg search path fix, fixes #8664
Browse files Browse the repository at this point in the history
  • Loading branch information
blazek committed May 26, 2014
1 parent 53a8adc commit 0eed3dc
Showing 1 changed file with 21 additions and 23 deletions.
44 changes: 21 additions & 23 deletions src/core/symbology-ng/qgssymbollayerv2utils.cpp
Expand Up @@ -3095,37 +3095,35 @@ QString QgsSymbolLayerV2Utils::symbolNameToPath( QString name )
}

QgsDebugMsg( "SvgPath: " + svgPath );
QFileInfo myInfo( name );
QString myFileName = myInfo.fileName(); // foo.svg
QString myLowestDir = myInfo.dir().dirName();
QString myLocalPath = svgPath + QString( myLowestDir.isEmpty() ? "" : "/" + myLowestDir ) + "/" + myFileName;
// Not sure why to lowest dir was used instead of full relative path, it was causing #8664
//QFileInfo myInfo( name );
//QString myFileName = myInfo.fileName(); // foo.svg
//QString myLowestDir = myInfo.dir().dirName();
//QString myLocalPath = svgPath + QString( myLowestDir.isEmpty() ? "" : "/" + myLowestDir ) + "/" + myFileName;
QString myLocalPath = svgPath + QDir::separator() + name;

QgsDebugMsg( "Alternative svg path: " + myLocalPath );
if ( QFile( myLocalPath ).exists() )
{
QgsDebugMsg( "Svg found in alternative path" );
return QFileInfo( myLocalPath ).canonicalFilePath();
}
else if ( myInfo.isRelative() )
{
QFileInfo pfi( QgsProject::instance()->fileName() );
QString alternatePath = pfi.canonicalPath() + QDir::separator() + name;
if ( pfi.exists() && QFile( alternatePath ).exists() )
{
QgsDebugMsg( "Svg found in alternative path" );
return QFileInfo( alternatePath ).canonicalFilePath();
}
else
{
QgsDebugMsg( "Svg not found in project path" );
}
}
else
{
//couldnt find the file, no happy ending :-(
QgsDebugMsg( "Computed alternate path but no svg there either" );
}
}

QFileInfo pfi( QgsProject::instance()->fileName() );
QString alternatePath = pfi.canonicalPath() + QDir::separator() + name;
if ( pfi.exists() && QFile( alternatePath ).exists() )
{
QgsDebugMsg( "Svg found in alternative path" );
return QFileInfo( alternatePath ).canonicalFilePath();
}
else
{
QgsDebugMsg( "Svg not found in project path" );
}
//couldnt find the file, no happy ending :-(
QgsDebugMsg( "Computed alternate path but no svg there either" );

return QString();
}

Expand Down

0 comments on commit 0eed3dc

Please sign in to comment.