@@ -124,7 +124,7 @@ QgsComposerMap::~QgsComposerMap()
124
124
}
125
125
}
126
126
127
- /* This function is called by paint() and cache() to render the map. It does not override any functions
127
+ /* This function is called by paint() to render the map. It does not override any functions
128
128
from QGraphicsItem. */
129
129
void QgsComposerMap::draw ( QPainter *painter, const QgsRectangle &extent, QSizeF size, double dpi, double *forceWidthScale )
130
130
{
@@ -218,7 +218,7 @@ void QgsComposerMap::cache()
218
218
disconnect ( mPainterJob .get (), &QgsMapRendererCustomPainterJob::finished, this , &QgsComposerMap::painterJobFinished );
219
219
QgsMapRendererCustomPainterJob *oldJob = mPainterJob .release ();
220
220
QPainter *oldPainter = mPainter .release ();
221
- QImage *oldImage = mCacheImage .release ();
221
+ QImage *oldImage = mCacheRenderingImage .release ();
222
222
connect ( oldJob, &QgsMapRendererCustomPainterJob::finished, this , [oldPainter, oldJob, oldImage]
223
223
{
224
224
oldJob->deleteLater ();
@@ -229,12 +229,12 @@ void QgsComposerMap::cache()
229
229
}
230
230
else
231
231
{
232
- mCacheImage .reset ( nullptr );
232
+ mCacheRenderingImage .reset ( nullptr );
233
233
}
234
234
235
235
Q_ASSERT ( !mPainterJob );
236
236
Q_ASSERT ( !mPainter );
237
- Q_ASSERT ( !mCacheImage );
237
+ Q_ASSERT ( !mCacheRenderingImage );
238
238
239
239
double horizontalVScaleFactor = horizontalViewScaleFactor ();
240
240
if ( horizontalVScaleFactor < 0 )
@@ -265,26 +265,26 @@ void QgsComposerMap::cache()
265
265
}
266
266
}
267
267
268
- mCacheImage .reset ( new QImage ( w, h, QImage::Format_ARGB32 ) );
268
+ mCacheRenderingImage .reset ( new QImage ( w, h, QImage::Format_ARGB32 ) );
269
269
270
270
// set DPI of the image
271
- mCacheImage ->setDotsPerMeterX ( 1000 * w / widthMM );
272
- mCacheImage ->setDotsPerMeterY ( 1000 * h / heightMM );
271
+ mCacheRenderingImage ->setDotsPerMeterX ( 1000 * w / widthMM );
272
+ mCacheRenderingImage ->setDotsPerMeterY ( 1000 * h / heightMM );
273
273
274
274
if ( hasBackground () )
275
275
{
276
276
// Initially fill image with specified background color. This ensures that layers with blend modes will
277
277
// preview correctly
278
- mCacheImage ->fill ( backgroundColor ().rgba () );
278
+ mCacheRenderingImage ->fill ( backgroundColor ().rgba () );
279
279
}
280
280
else
281
281
{
282
282
// no background, but start with empty fill to avoid artifacts
283
- mCacheImage ->fill ( QColor ( 255 , 255 , 255 , 0 ).rgba () );
283
+ mCacheRenderingImage ->fill ( QColor ( 255 , 255 , 255 , 0 ).rgba () );
284
284
}
285
285
286
- mPainter .reset ( new QPainter ( mCacheImage .get () ) );
287
- QgsMapSettings settings ( mapSettings ( ext, QSizeF ( w, h ), mCacheImage ->logicalDpiX () ) );
286
+ mPainter .reset ( new QPainter ( mCacheRenderingImage .get () ) );
287
+ QgsMapSettings settings ( mapSettings ( ext, QSizeF ( w, h ), mCacheRenderingImage ->logicalDpiX () ) );
288
288
mPainterJob .reset ( new QgsMapRendererCustomPainterJob ( settings, mPainter .get () ) );
289
289
connect ( mPainterJob .get (), &QgsMapRendererCustomPainterJob::finished, this , &QgsComposerMap::painterJobFinished );
290
290
mPainterJob ->start ();
@@ -296,6 +296,7 @@ void QgsComposerMap::painterJobFinished()
296
296
mPainterJob .reset ( nullptr );
297
297
mPainter .reset ( nullptr );
298
298
mCacheUpdated = true ;
299
+ mCacheFinalImage = std::move ( mCacheRenderingImage );
299
300
updateItem ();
300
301
}
301
302
@@ -327,22 +328,22 @@ void QgsComposerMap::paint( QPainter *painter, const QStyleOptionGraphicsItem *,
327
328
}
328
329
else if ( mComposition ->plotStyle () == QgsComposition::Preview )
329
330
{
330
- if ( !mCacheImage || mCacheImage ->isNull () )
331
+ if ( !mCacheFinalImage || mCacheFinalImage ->isNull () )
331
332
{
332
333
cache ();
333
334
return ;
334
335
}
335
336
336
337
// Background color is already included in cached image, so no need to draw
337
338
338
- double imagePixelWidth = mCacheImage ->width (); // how many pixels of the image are for the map extent?
339
+ double imagePixelWidth = mCacheFinalImage ->width (); // how many pixels of the image are for the map extent?
339
340
double scale = rect ().width () / imagePixelWidth;
340
341
341
342
painter->save ();
342
343
343
344
painter->translate ( mXOffset , mYOffset );
344
345
painter->scale ( scale, scale );
345
- painter->drawImage ( 0 , 0 , *mCacheImage );
346
+ painter->drawImage ( 0 , 0 , *mCacheFinalImage );
346
347
347
348
// restore rotation
348
349
painter->restore ();
0 commit comments