File tree 2 files changed +10
-6
lines changed
2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -93,6 +93,7 @@ QgsSvgCache::QgsSvgCache( QObject *parent )
93
93
, mLeastRecentEntry( 0 )
94
94
, mMostRecentEntry( 0 )
95
95
{
96
+ mMissingSvg = QString ( " <svg width='10' height='10'><text x='5' y='10' font-size='10' text-anchor='middle'>?</text></svg>" ).toAscii ();
96
97
}
97
98
98
99
QgsSvgCache::~QgsSvgCache ()
@@ -246,20 +247,20 @@ QByteArray QgsSvgCache::getImageData( const QString &path ) const
246
247
}
247
248
else
248
249
{
249
- return QByteArray () ;
250
+ return mMissingSvg ;
250
251
}
251
252
}
252
253
253
254
// maybe it's a url...
254
255
if ( !path.contains ( " ://" ) ) // otherwise short, relative SVG paths might be considered URLs
255
256
{
256
- return QByteArray () ;
257
+ return mMissingSvg ;
257
258
}
258
259
259
260
QUrl svgUrl ( path );
260
261
if ( !svgUrl.isValid () )
261
262
{
262
- return QByteArray () ;
263
+ return mMissingSvg ;
263
264
}
264
265
265
266
// check whether it's a url pointing to a local file
@@ -275,7 +276,7 @@ QByteArray QgsSvgCache::getImageData( const QString &path ) const
275
276
}
276
277
277
278
// not found...
278
- return QByteArray () ;
279
+ return mMissingSvg ;
279
280
}
280
281
281
282
// the url points to a remote resource, download it!
@@ -331,15 +332,15 @@ QByteArray QgsSvgCache::getImageData( const QString &path ) const
331
332
QgsMessageLog::logMessage ( tr ( " SVG request error [status: %1 - reason phrase: %2]" ).arg ( status.toInt () ).arg ( phrase.toString () ), tr ( " SVG" ) );
332
333
333
334
reply->deleteLater ();
334
- return QByteArray () ;
335
+ return mMissingSvg ;
335
336
}
336
337
337
338
QString contentType = reply->header ( QNetworkRequest::ContentTypeHeader ).toString ();
338
339
QgsDebugMsg ( " contentType: " + contentType );
339
340
if ( !contentType.startsWith ( " image/svg+xml" , Qt::CaseInsensitive ) )
340
341
{
341
342
reply->deleteLater ();
342
- return QByteArray () ;
343
+ return mMissingSvg ;
343
344
}
344
345
345
346
// read the image data
Original file line number Diff line number Diff line change @@ -147,6 +147,9 @@ class CORE_EXPORT QgsSvgCache : public QObject
147
147
148
148
/* *For debugging*/
149
149
void printEntryList ();
150
+
151
+ /* * SVG content to be rendered if SVG file was not found. */
152
+ QByteArray mMissingSvg ;
150
153
};
151
154
152
155
#endif // QGSSVGCACHE_H
You can’t perform that action at this time.
0 commit comments