Skip to content
Permalink
Browse files

Fix #10271 (crash from race condition in SVG cache when using paralle…

…l rendering)
  • Loading branch information
wonder-sk committed Jun 15, 2014
1 parent 9d8a842 commit f3ff3b4fe6784a3beadebd0c83bdbf1fd6cdb50f
Showing with 8 additions and 0 deletions.
  1. +4 −0 src/core/symbology-ng/qgssvgcache.cpp
  2. +4 −0 src/core/symbology-ng/qgssvgcache.h
@@ -109,6 +109,8 @@ QgsSvgCache::~QgsSvgCache()
const QImage& QgsSvgCache::svgAsImage( const QString& file, double size, const QColor& fill, const QColor& outline, double outlineWidth,
double widthScaleFactor, double rasterScaleFactor, bool& fitsInCache )
{
QMutexLocker locker( &mMutex );

fitsInCache = true;
QgsSvgCacheEntry* currentEntry = cacheEntry( file, size, fill, outline, outlineWidth, widthScaleFactor, rasterScaleFactor );

@@ -152,6 +154,8 @@ const QImage& QgsSvgCache::svgAsImage( const QString& file, double size, const Q
const QPicture& QgsSvgCache::svgAsPicture( const QString& file, double size, const QColor& fill, const QColor& outline, double outlineWidth,
double widthScaleFactor, double rasterScaleFactor, bool forceVectorOutput )
{
QMutexLocker locker( &mMutex );

QgsSvgCacheEntry* currentEntry = cacheEntry( file, size, fill, outline, outlineWidth, widthScaleFactor, rasterScaleFactor );

//if current entry picture is 0: cache picture for entry
@@ -21,6 +21,7 @@
#include <QColor>
#include <QMap>
#include <QMultiHash>
#include <QMutex>
#include <QString>
#include <QUrl>

@@ -176,6 +177,9 @@ class CORE_EXPORT QgsSvgCache : public QObject

/** SVG content to be rendered if SVG file was not found. */
QByteArray mMissingSvg;

//! Mutex to prevent concurrent access to the class from multiple threads at once (may corrupt the entries otherwise).
QMutex mMutex;
};

#endif // QGSSVGCACHE_H

0 comments on commit f3ff3b4

Please sign in to comment.
You can’t perform that action at this time.