File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed
Expand file tree Collapse file tree 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 )
9393 , mLeastRecentEntry( 0 )
9494 , mMostRecentEntry( 0 )
9595{
96+ mMissingSvg = QString ( " <svg width='10' height='10'><text x='5' y='10' font-size='10' text-anchor='middle'>?</text></svg>" ).toAscii ();
9697}
9798
9899QgsSvgCache::~QgsSvgCache ()
@@ -246,20 +247,20 @@ QByteArray QgsSvgCache::getImageData( const QString &path ) const
246247 }
247248 else
248249 {
249- return QByteArray () ;
250+ return mMissingSvg ;
250251 }
251252 }
252253
253254 // maybe it's a url...
254255 if ( !path.contains ( " ://" ) ) // otherwise short, relative SVG paths might be considered URLs
255256 {
256- return QByteArray () ;
257+ return mMissingSvg ;
257258 }
258259
259260 QUrl svgUrl ( path );
260261 if ( !svgUrl.isValid () )
261262 {
262- return QByteArray () ;
263+ return mMissingSvg ;
263264 }
264265
265266 // check whether it's a url pointing to a local file
@@ -275,7 +276,7 @@ QByteArray QgsSvgCache::getImageData( const QString &path ) const
275276 }
276277
277278 // not found...
278- return QByteArray () ;
279+ return mMissingSvg ;
279280 }
280281
281282 // the url points to a remote resource, download it!
@@ -331,15 +332,15 @@ QByteArray QgsSvgCache::getImageData( const QString &path ) const
331332 QgsMessageLog::logMessage ( tr ( " SVG request error [status: %1 - reason phrase: %2]" ).arg ( status.toInt () ).arg ( phrase.toString () ), tr ( " SVG" ) );
332333
333334 reply->deleteLater ();
334- return QByteArray () ;
335+ return mMissingSvg ;
335336 }
336337
337338 QString contentType = reply->header ( QNetworkRequest::ContentTypeHeader ).toString ();
338339 QgsDebugMsg ( " contentType: " + contentType );
339340 if ( !contentType.startsWith ( " image/svg+xml" , Qt::CaseInsensitive ) )
340341 {
341342 reply->deleteLater ();
342- return QByteArray () ;
343+ return mMissingSvg ;
343344 }
344345
345346 // read the image data
Original file line number Diff line number Diff line change @@ -147,6 +147,9 @@ class CORE_EXPORT QgsSvgCache : public QObject
147147
148148 /* *For debugging*/
149149 void printEntryList ();
150+
151+ /* * SVG content to be rendered if SVG file was not found. */
152+ QByteArray mMissingSvg ;
150153};
151154
152155#endif // QGSSVGCACHE_H
You can’t perform that action at this time.
0 commit comments