Skip to content
Permalink
Browse files

Simple marker: use limit for cache image size. Fixes #8386

  • Loading branch information
mhugent committed Aug 15, 2013
1 parent 65dfdf1 commit 74367c5b7f182970c084da56ab728c153b7f5ab6
Showing with 18 additions and 3 deletions.
  1. +12 −2 src/core/symbology-ng/qgsmarkersymbollayerv2.cpp
  2. +6 −1 src/core/symbology-ng/qgsmarkersymbollayerv2.h
@@ -200,7 +200,10 @@ void QgsSimpleMarkerSymbolLayerV2::startRender( QgsSymbolV2RenderContext& contex

if ( mUsingCache )
{
prepareCache( context );
if ( !prepareCache( context ) )
{
mUsingCache = false;
}
}
else
{
@@ -212,7 +215,7 @@ void QgsSimpleMarkerSymbolLayerV2::startRender( QgsSymbolV2RenderContext& contex
}


void QgsSimpleMarkerSymbolLayerV2::prepareCache( QgsSymbolV2RenderContext& context )
bool QgsSimpleMarkerSymbolLayerV2::prepareCache( QgsSymbolV2RenderContext& context )
{
double scaledSize = mSize * QgsSymbolLayerV2Utils::lineWidthScaleFactor( context.renderContext(), mSizeUnit );

@@ -221,6 +224,11 @@ void QgsSimpleMarkerSymbolLayerV2::prepareCache( QgsSymbolV2RenderContext& conte
int imageSize = (( int ) scaledSize + pw ) / 2 * 2 + 1; // make image width, height odd; account for pen width
double center = imageSize / 2.0;

if ( imageSize > mMaximumCacheWidth )
{
return false;
}

mCache = QImage( QSize( imageSize, imageSize ), QImage::Format_ARGB32_Premultiplied );
mCache.fill( 0 );

@@ -263,6 +271,8 @@ void QgsSimpleMarkerSymbolLayerV2::prepareCache( QgsSymbolV2RenderContext& conte
drawMarker( &p, context );
p.end();
}

return true;
}

void QgsSimpleMarkerSymbolLayerV2::stopRender( QgsSymbolV2RenderContext& context )
@@ -83,7 +83,9 @@ class CORE_EXPORT QgsSimpleMarkerSymbolLayerV2 : public QgsMarkerSymbolLayerV2
bool prepareShape( QString name = QString() );
bool preparePath( QString name = QString() );

void prepareCache( QgsSymbolV2RenderContext& context );
/**Prepares cache image
@return true in case of success, false if cache image size too large*/
bool prepareCache( QgsSymbolV2RenderContext& context );

QColor mBorderColor;
double mOutlineWidth;
@@ -98,6 +100,9 @@ class CORE_EXPORT QgsSimpleMarkerSymbolLayerV2 : public QgsMarkerSymbolLayerV2
QBrush mSelBrush;
QImage mSelCache;
bool mUsingCache;

//Maximum width/height of cache image
static const int mMaximumCacheWidth = 3000;
};

//////////

0 comments on commit 74367c5

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