Skip to content

Commit 1166fbf

Browse files
author
jef
committed
fix #1751
git-svn-id: http://svn.osgeo.org/qgis/trunk@10987 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 29450dc commit 1166fbf

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

src/core/symbology/qgsmarkercatalogue.cpp

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,14 @@ QImage QgsMarkerCatalogue::imageMarker( QString fullName, double size, QPen pen,
145145
//
146146
// Now pass the paintdevice along to have the marker rendered on it
147147
//
148+
if ( fullName.left( 4 ) == "svg:" )
149+
{
150+
if ( svgMarker( &myPainter, fullName.mid( 4 ), size ) )
151+
return myImage;
152+
153+
QgsDebugMsg( QString( "%1 not found - replacing with hard:circle" ).arg( fullName ) );
154+
fullName = "hard:circle";
155+
}
148156

149157
if ( fullName.left( 5 ) == "hard:" )
150158
{
@@ -157,11 +165,7 @@ QImage QgsMarkerCatalogue::imageMarker( QString fullName, double size, QPen pen,
157165
#endif
158166
return myImage;
159167
}
160-
else if ( fullName.left( 4 ) == "svg:" )
161-
{
162-
svgMarker( &myPainter, fullName.mid( 4 ), size );
163-
return myImage;
164-
}
168+
165169
return QImage(); // empty
166170
}
167171

@@ -192,25 +196,33 @@ QPicture QgsMarkerCatalogue::pictureMarker( QString fullName, double size, QPen
192196
//
193197
// Now pass the paintdevice along to have the marker rndered on it
194198
//
199+
if ( fullName.left( 4 ) == "svg:" )
200+
{
201+
if ( svgMarker( &myPainter, fullName.mid( 4 ), size ) )
202+
return myPicture;
203+
204+
QgsDebugMsg( QString( "%1 not found - replacing with hard:circle" ).arg( fullName ) );
205+
fullName = "hard:circle";
206+
}
195207

196208
if ( fullName.left( 5 ) == "hard:" )
197209
{
198210
hardMarker( &myPainter, ( int ) size, fullName.mid( 5 ), size, pen, brush, qtBug );
199211
return myPicture;
200212
}
201-
else if ( fullName.left( 4 ) == "svg:" )
202-
{
203-
svgMarker( &myPainter, fullName.mid( 4 ), size );
204-
return myPicture;
205-
}
213+
206214
return QPicture(); // empty
207215
}
208216

209-
void QgsMarkerCatalogue::svgMarker( QPainter * thepPainter, QString fileName, double scaleFactor )
217+
bool QgsMarkerCatalogue::svgMarker( QPainter * thepPainter, QString fileName, double scaleFactor )
210218
{
211219
QSvgRenderer mySVG;
212-
mySVG.load( fileName );
220+
if ( !mySVG.load( fileName ) )
221+
return false;
222+
213223
mySVG.render( thepPainter );
224+
225+
return true;
214226
}
215227

216228
void QgsMarkerCatalogue::hardMarker( QPainter * thepPainter, int imageSize, QString name, double s, QPen pen, QBrush brush, bool qtBug )

src/core/symbology/qgsmarkercatalogue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class CORE_EXPORT QgsMarkerCatalogue
5252

5353
/** Returns a pixmap given a file name of a svg marker
5454
* NOTE: this method needs to be public static for QgsMarkerDialog::visualizeMarkers */
55-
static void svgMarker( QPainter * thepPainter, QString name, double size );
55+
static bool svgMarker( QPainter * thepPainter, QString name, double size );
5656
private:
5757

5858
/**Constructor*/

0 commit comments

Comments
 (0)