Skip to content

Commit 9b5c5b0

Browse files
committed
Run WFS feature counter task in separate thread
1 parent 365fbed commit 9b5c5b0

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

src/providers/wfs/qgswfsrequest.cpp

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include <QEventLoop>
2525
#include <QNetworkCacheMetaData>
2626
#include <QCryptographicHash> // just for testin file:// fake_qgis_http_endpoint hack
27+
#include <QFuture>
28+
#include <QtConcurrent>
2729

2830
const qint64 READ_BUFFER_SIZE_HINT = 1024 * 1024;
2931

@@ -140,12 +142,27 @@ bool QgsWfsRequest::sendGET( const QUrl &url, bool synchronous, bool forceRefres
140142

141143
if ( !synchronous )
142144
return true;
145+
else
146+
{
147+
QEventLoop loop;
148+
connect( this, &QgsWfsRequest::downloadFinished, &loop, &QEventLoop::quit );
143149

144-
QEventLoop loop;
145-
connect( this, &QgsWfsRequest::downloadFinished, &loop, &QEventLoop::quit );
146-
loop.exec( QEventLoop::ExcludeUserInputEvents );
150+
if ( QThread::currentThread() == QApplication::instance()->thread() )
151+
{
152+
QFuture<void> future = QtConcurrent::run( [ &loop ]()
153+
{
154+
loop.exec();
155+
} );
147156

148-
return mErrorMessage.isEmpty();
157+
future.waitForFinished();
158+
}
159+
else
160+
{
161+
loop.exec();
162+
}
163+
164+
return mErrorMessage.isEmpty();
165+
}
149166
}
150167

151168
bool QgsWfsRequest::sendPOST( const QUrl &url, const QString &contentTypeHeader, const QByteArray &data )

0 commit comments

Comments
 (0)