Skip to content

Commit

Permalink
Run WFS feature counter task in separate thread
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Jun 14, 2018
1 parent 365fbed commit 9b5c5b0
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/providers/wfs/qgswfsrequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include <QEventLoop>
#include <QNetworkCacheMetaData>
#include <QCryptographicHash> // just for testin file:// fake_qgis_http_endpoint hack
#include <QFuture>
#include <QtConcurrent>

const qint64 READ_BUFFER_SIZE_HINT = 1024 * 1024;

Expand Down Expand Up @@ -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<void> 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 )
Expand Down

0 comments on commit 9b5c5b0

Please sign in to comment.