@@ -220,37 +220,42 @@ void QgsSymbol::setNamedPointSymbol( QString name )
220220 // by using the qgis svg dir from this local machine
221221 // one day when user specified svg are allowed we need
222222 // to adjust this logic probably...
223- QString svgPath = QgsApplication::svgPath ();
224- QgsDebugMsg ( " SvgPath: " + svgPath );
225- QFileInfo myInfo ( myTempName );
226- QString myFileName = myInfo.fileName (); // foo.svg
227- QString myLowestDir = myInfo.dir ().dirName ();
228- QString myLocalPath = svgPath + QDir::separator () +
229- myLowestDir + QDir::separator () +
230- myFileName;
231- QgsDebugMsg ( " Alternative svg path: " + myLocalPath );
232- if ( QFile ( myLocalPath ).exists () )
233- {
234- name = " svg:" + myLocalPath;
235- QgsDebugMsg ( " Svg found in alternative path" );
236- }
237- else if ( myInfo.isRelative () )
238- {
239- QFileInfo pfi ( QgsProject::instance ()->fileName () );
240- if ( pfi.exists () && QFile ( pfi.canonicalPath () + QDir::separator () + myTempName ).exists () )
241- {
242- name = " svg:" + pfi.canonicalPath () + QDir::separator () + myTempName;
243- QgsDebugMsg ( " Svg found in alternative path" );
244- }
245- else
246- {
247- QgsDebugMsg ( " Svg not found in project path" );
248- }
249- }
250- else
223+ QStringList svgPaths = QgsApplication::svgPaths ();
224+
225+ for ( int i=0 ; i<svgPaths.size (); i++)
251226 {
252- // couldnt find the file, no happy ending :-(
253- QgsDebugMsg ( " Computed alternate path but no svg there either" );
227+ QgsDebugMsg ( " SvgPath: " + svgPaths[i] );
228+ QFileInfo myInfo ( myTempName );
229+ QString myFileName = myInfo.fileName (); // foo.svg
230+ QString myLowestDir = myInfo.dir ().dirName ();
231+ QString myLocalPath = svgPaths[i] + QDir::separator () +
232+ myLowestDir + QDir::separator () +
233+ myFileName;
234+ QgsDebugMsg ( " Alternative svg path: " + myLocalPath );
235+ if ( QFile ( myLocalPath ).exists () )
236+ {
237+ name = " svg:" + myLocalPath;
238+ QgsDebugMsg ( " Svg found in alternative path" );
239+ }
240+ else if ( myInfo.isRelative () )
241+ {
242+ QFileInfo pfi ( QgsProject::instance ()->fileName () );
243+ if ( pfi.exists () && QFile ( pfi.canonicalPath () + QDir::separator () + myTempName ).exists () )
244+ {
245+ name = " svg:" + pfi.canonicalPath () + QDir::separator () + myTempName;
246+ QgsDebugMsg ( " Svg found in alternative path" );
247+ break ;
248+ }
249+ else
250+ {
251+ QgsDebugMsg ( " Svg not found in project path" );
252+ }
253+ }
254+ else
255+ {
256+ // couldnt find the file, no happy ending :-(
257+ QgsDebugMsg ( " Computed alternate path but no svg there either" );
258+ }
254259 }
255260 }
256261 }
@@ -511,11 +516,17 @@ bool QgsSymbol::writeXML( QDomNode & item, QDomDocument & document, const QgsVec
511516 {
512517 name = fi.canonicalFilePath ();
513518
514- QString dir = QFileInfo ( QgsApplication::svgPath () ). canonicalFilePath ();
519+ QStringList svgPaths = QgsApplication::svgPaths ();
515520
516- if ( !dir. isEmpty () && name. startsWith ( dir ) )
521+ for ( int i= 0 ; i<svgPaths. size (); i++ )
517522 {
518- name = name.mid ( dir.size () );
523+ QString dir = QFileInfo ( svgPaths[i] ).canonicalFilePath ();
524+
525+ if ( !dir.isEmpty () && name.startsWith ( dir ) )
526+ {
527+ name = name.mid ( dir.size () );
528+ break ;
529+ }
519530 }
520531 }
521532
0 commit comments