@@ -220,37 +220,42 @@ void QgsSymbol::setNamedPointSymbol( QString name )
220
220
// by using the qgis svg dir from this local machine
221
221
// one day when user specified svg are allowed we need
222
222
// 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++)
251
226
{
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
+ }
254
259
}
255
260
}
256
261
}
@@ -511,11 +516,17 @@ bool QgsSymbol::writeXML( QDomNode & item, QDomDocument & document, const QgsVec
511
516
{
512
517
name = fi.canonicalFilePath ();
513
518
514
- QString dir = QFileInfo ( QgsApplication::svgPath () ). canonicalFilePath ();
519
+ QStringList svgPaths = QgsApplication::svgPaths ();
515
520
516
- if ( !dir. isEmpty () && name. startsWith ( dir ) )
521
+ for ( int i= 0 ; i<svgPaths. size (); i++ )
517
522
{
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
+ }
519
530
}
520
531
}
521
532
0 commit comments