Skip to content

Commit 2543e07

Browse files
committedJul 6, 2017
Better assert messages
Issues is actually when prepare/postProcess is called in a different thread to context - it doesn't have to be the main thread
1 parent 1b2086e commit 2543e07

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

‎src/core/processing/qgsprocessingalgorithm.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ QVariantMap QgsProcessingAlgorithm::run( const QVariantMap &parameters, QgsProce
341341

342342
bool QgsProcessingAlgorithm::prepare( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
343343
{
344-
Q_ASSERT_X( QApplication::instance()->thread() == QThread::currentThread(), "QgsProcessingAlgorithm::prepare", "prepare() must be called from the main thread" );
344+
Q_ASSERT_X( QApplication::instance()->thread() == context.temporaryLayerStore()->thread(), "QgsProcessingAlgorithm::prepare", "prepare() must be called from the same thread as context was created in" );
345345
Q_ASSERT_X( !mHasPrepared, "QgsProcessingAlgorithm::prepare", "prepare() has already been called for the algorithm instance" );
346346
try
347347
{
@@ -376,7 +376,7 @@ bool QgsProcessingAlgorithm::runPrepared( QgsProcessingContext &context, QgsProc
376376

377377
QVariantMap QgsProcessingAlgorithm::postProcess( QgsProcessingContext &context, QgsProcessingFeedback *feedback )
378378
{
379-
Q_ASSERT_X( QApplication::instance()->thread() == QThread::currentThread(), "QgsProcessingAlgorithm::postProcess", "postProcess() must be called from the main thread" );
379+
Q_ASSERT_X( QApplication::instance()->thread() == context.temporaryLayerStore()->thread(), "QgsProcessingAlgorithm::postProcess", "postProcess() must be called from the same thread the context was created in" );
380380
Q_ASSERT_X( mHasExecuted, "QgsProcessingAlgorithm::postProcess", "runPrepared() was not called for the algorithm instance" );
381381
Q_ASSERT_X( !mHasPostProcessed, "QgsProcessingAlgorithm::postProcess", "postProcess() was already called for this algorithm instance" );
382382

0 commit comments

Comments
 (0)
Please sign in to comment.