Commit 6a2887e1 authored by Bernhard Beschow's avatar Bernhard Beschow
Browse files

call QNetworkAccessManager::get() in the GUI thread

* this is done in the other runners as well

CCBUG: 257376
parent 45a9056e
......@@ -86,17 +86,17 @@ void OSRMRunner::retrieveRoute( const RouteRequest *route )
m_cachedHints = newChecksums;
m_hintChecksum = invalidEntry;
QNetworkRequest request = QNetworkRequest( QUrl( url ) );
request.setRawHeader( "User-Agent", TinyWebBrowser::userAgent( "Browser", "OSRMRunner" ) );
QNetworkReply *reply = m_networkAccessManager->get( request );
connect( reply, SIGNAL( error( QNetworkReply::NetworkError ) ),
this, SLOT( handleError( QNetworkReply::NetworkError ) ) );
m_request = QNetworkRequest( QUrl( url ) );
m_request.setRawHeader( "User-Agent", TinyWebBrowser::userAgent( "Browser", "OSRMRunner" ) );
QEventLoop eventLoop;
connect( this, SIGNAL( routeCalculated( GeoDataDocument* ) ),
&eventLoop, SLOT( quit() ) );
// @todo FIXME Must currently be done in the main thread, see bug 257376
QTimer::singleShot( 0, this, SLOT( get() ) );
eventLoop.exec();
}
......@@ -120,6 +120,13 @@ void OSRMRunner::handleError( QNetworkReply::NetworkError error )
mDebug() << " Error when retrieving OSRM route: " << error;
}
void OSRMRunner::get()
{
QNetworkReply *reply = m_networkAccessManager->get( m_request );
connect( reply, SIGNAL( error( QNetworkReply::NetworkError ) ),
this, SLOT( handleError( QNetworkReply::NetworkError ) ), Qt::DirectConnection );
}
void OSRMRunner::append(QString *input, const QString &key, const QString &value) const
{
*input += "&" + key + "=" + value;
......
......@@ -46,6 +46,8 @@ private Q_SLOTS:
/** A network error occurred */
void handleError( QNetworkReply::NetworkError );
void get();
private:
void append( QString* input, const QString &key, const QString &value ) const;
......@@ -57,6 +59,8 @@ private:
QNetworkAccessManager *m_networkAccessManager;
QNetworkRequest m_request;
static QVector<QPair<GeoDataCoordinates,QString> > m_cachedHints;
static QString m_hintChecksum;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment