Skip to content
Permalink
Browse files
svg search path fix, fixes #8664
  • Loading branch information
blazek committed May 26, 2014
1 parent 53a8adc commit 0eed3dccd9937956aa7829c053664ab0de7a844f
Showing with 21 additions and 23 deletions.
  1. +21 −23 src/core/symbology-ng/qgssymbollayerv2utils.cpp
@@ -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();
}

0 comments on commit 0eed3dc

Please sign in to comment.