Skip to content
Permalink
Browse files

Merge pull request #3120 from manisandro/rendering_crash

Guard against possible crash by using destroyed QgsMapRendererCustomPainterJob
  • Loading branch information
wonder-sk committed Jun 1, 2016
2 parents 73ab289 + 759dd9d commit 996e2e1997214018a928fc8e34e1ee65f5476ea2
Showing with 16 additions and 0 deletions.
  1. +8 −0 src/core/qgsmaprenderercustompainterjob.cpp
  2. +8 −0 src/core/qgsmaprendererparalleljob.cpp
@@ -97,6 +97,14 @@ void QgsMapRendererCustomPainterJob::start()
}

mLayerJobs = prepareJobs( mPainter, mLabelingEngine, mLabelingEngineV2 );
// prepareJobs calls mapLayer->createMapRenderer may involve cloning a RasterDataProvider,
// whose constructor may need to download some data (i.e. WMS, AMS) and doing so runs a
// QEventLoop waiting for the network request to complete. If unluckily someone calls
// mapCanvas->refresh() while this is happening, QgsMapRendererCustomPainterJob::cancel is
// called, deleting the QgsMapRendererCustomPainterJob while this function is running.
// Hence we need to check whether the job is still active before proceeding
if ( !isActive() )
return;

QgsDebugMsg( "Rendering prepared in (seconds): " + QString( "%1" ).arg( prepareTime.elapsed() / 1000.0 ) );

@@ -75,6 +75,14 @@ void QgsMapRendererParallelJob::start()
}

mLayerJobs = prepareJobs( nullptr, mLabelingEngine, mLabelingEngineV2 );
// prepareJobs calls mapLayer->createMapRenderer may involve cloning a RasterDataProvider,
// whose constructor may need to download some data (i.e. WMS, AMS) and doing so runs a
// QEventLoop waiting for the network request to complete. If unluckily someone calls
// mapCanvas->refresh() while this is happening, QgsMapRendererCustomPainterJob::cancel is
// called, deleting the QgsMapRendererCustomPainterJob while this function is running.
// Hence we need to check whether the job is still active before proceeding
if ( !isActive() )
return;

QgsDebugMsg( QString( "QThreadPool max thread count is %1" ).arg( QThreadPool::globalInstance()->maxThreadCount() ) );

0 comments on commit 996e2e1

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