Skip to content

Commit c97645e

Browse files
arnaud-morvannyalldawson
authored andcommittedJan 28, 2019
Do not overwrite renderContext in QgsMapRendererJob::drawLabeling
Dedicated QgsRenderContext is already created and configured in prepareLabelingJob.
1 parent 4d33588 commit c97645e

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed
 

‎python/core/auto_generated/qgsmaprendererjob.sip.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ emitted when asynchronous rendering is finished (or canceled).
183183

184184

185185

186+
186187
};
187188

188189

‎src/core/qgsmaprenderercustompainterjob.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -295,12 +295,12 @@ void QgsMapRendererCustomPainterJob::doRender()
295295
mLabelJob.img->fill( 0 );
296296
painter.begin( mLabelJob.img );
297297
mLabelJob.context.setPainter( &painter );
298-
drawLabeling( mSettings, mLabelJob.context, mLabelingEngineV2.get(), &painter );
298+
drawLabeling( mLabelJob.context, mLabelingEngineV2.get(), &painter );
299299
painter.end();
300300
}
301301
else
302302
{
303-
drawLabeling( mSettings, mLabelJob.context, mLabelingEngineV2.get(), mPainter );
303+
drawLabeling( mLabelJob.context, mLabelingEngineV2.get(), mPainter );
304304
}
305305

306306
mLabelJob.complete = true;
@@ -318,8 +318,7 @@ void QgsMapRendererCustomPainterJob::doRender()
318318
QgsDebugMsgLevel( "Rendering completed in (seconds): " + QString( "%1" ).arg( renderTime.elapsed() / 1000.0 ), 2 );
319319
}
320320

321-
322-
void QgsMapRendererJob::drawLabeling( const QgsMapSettings &settings, QgsRenderContext &renderContext, QgsLabelingEngine *labelingEngine2, QPainter *painter )
321+
void QgsMapRendererJob::drawLabeling( QgsRenderContext &renderContext, QgsLabelingEngine *labelingEngine2, QPainter *painter )
323322
{
324323
QgsDebugMsgLevel( QStringLiteral( "Draw labeling start" ), 5 );
325324

@@ -329,22 +328,22 @@ void QgsMapRendererJob::drawLabeling( const QgsMapSettings &settings, QgsRenderC
329328
// Reset the composition mode before rendering the labels
330329
painter->setCompositionMode( QPainter::CompositionMode_SourceOver );
331330

332-
// TODO: this is not ideal - we could override rendering stopped flag that has been set in meanwhile
333-
renderContext = QgsRenderContext::fromMapSettings( settings );
334331
renderContext.setPainter( painter );
335332

336333
if ( labelingEngine2 )
337334
{
338-
// set correct extent
339-
renderContext.setExtent( settings.visibleExtent() );
340-
renderContext.setCoordinateTransform( QgsCoordinateTransform() );
341-
342335
labelingEngine2->run( renderContext );
343336
}
344337

345338
QgsDebugMsg( QStringLiteral( "Draw labeling took (seconds): %1" ).arg( t.elapsed() / 1000. ) );
346339
}
347340

341+
void QgsMapRendererJob::drawLabeling( const QgsMapSettings &settings, QgsRenderContext &renderContext, QgsLabelingEngine *labelingEngine2, QPainter *painter )
342+
{
343+
Q_UNUSED( settings );
344+
345+
drawLabeling( renderContext, labelingEngine2, painter );
346+
}
348347

349348
bool QgsMapRendererJob::needTemporaryImage( QgsMapLayer *ml )
350349
{

‎src/core/qgsmaprendererjob.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,14 @@ class CORE_EXPORT QgsMapRendererJob : public QObject
286286
*/
287287
void cleanupLabelJob( LabelRenderJob &job ) SIP_SKIP;
288288

289+
/**
290+
* \note not available in Python bindings
291+
* \deprecated Will be removed in QGIS 4.0
292+
*/
293+
Q_DECL_DEPRECATED static void drawLabeling( const QgsMapSettings &settings, QgsRenderContext &renderContext, QgsLabelingEngine *labelingEngine2, QPainter *painter ) SIP_SKIP;
294+
289295
//! \note not available in Python bindings
290-
static void drawLabeling( const QgsMapSettings &settings, QgsRenderContext &renderContext, QgsLabelingEngine *labelingEngine2, QPainter *painter ) SIP_SKIP;
296+
static void drawLabeling( QgsRenderContext &renderContext, QgsLabelingEngine *labelingEngine2, QPainter *painter ) SIP_SKIP;
291297

292298
private:
293299

‎src/core/qgsmaprendererparalleljob.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ void QgsMapRendererParallelJob::renderLabelsStatic( QgsMapRendererParallelJob *s
297297
// draw the labels!
298298
try
299299
{
300-
drawLabeling( self->mSettings, job.context, self->mLabelingEngineV2.get(), &painter );
300+
drawLabeling( job.context, self->mLabelingEngineV2.get(), &painter );
301301
}
302302
catch ( QgsException &e )
303303
{

0 commit comments

Comments
 (0)
Please sign in to comment.