From 9b5c5b0081e2cc4baedee428a248485d418655ea Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Wed, 23 May 2018 12:17:27 +0200 Subject: [PATCH] Run WFS feature counter task in separate thread --- src/providers/wfs/qgswfsrequest.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/providers/wfs/qgswfsrequest.cpp b/src/providers/wfs/qgswfsrequest.cpp index 88edee67011..f565a15e1a3 100644 --- a/src/providers/wfs/qgswfsrequest.cpp +++ b/src/providers/wfs/qgswfsrequest.cpp @@ -24,6 +24,8 @@ #include #include #include // just for testin file:// fake_qgis_http_endpoint hack +#include +#include const qint64 READ_BUFFER_SIZE_HINT = 1024 * 1024; @@ -140,12 +142,27 @@ bool QgsWfsRequest::sendGET( const QUrl &url, bool synchronous, bool forceRefres if ( !synchronous ) return true; + else + { + QEventLoop loop; + connect( this, &QgsWfsRequest::downloadFinished, &loop, &QEventLoop::quit ); - QEventLoop loop; - connect( this, &QgsWfsRequest::downloadFinished, &loop, &QEventLoop::quit ); - loop.exec( QEventLoop::ExcludeUserInputEvents ); + if ( QThread::currentThread() == QApplication::instance()->thread() ) + { + QFuture future = QtConcurrent::run( [ &loop ]() + { + loop.exec(); + } ); - return mErrorMessage.isEmpty(); + future.waitForFinished(); + } + else + { + loop.exec(); + } + + return mErrorMessage.isEmpty(); + } } bool QgsWfsRequest::sendPOST( const QUrl &url, const QString &contentTypeHeader, const QByteArray &data )