Skip to content
Permalink
Browse files

Guard against possible crash by using destroyed QgsMapRendererCustomP…

…ainterJob
  • Loading branch information
manisandro committed May 27, 2016
1 parent 27c5f78 commit 759dd9d1212521f9c39ea9f0d2f92aa3091f05dc
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 759dd9d

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