Commit a520e811 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
(cherry picked from commit 2ff41793)
parent 02ed3820
......@@ -33,7 +33,8 @@ namespace Marble
MapQuestRunner::MapQuestRunner( QObject *parent ) :
MarbleAbstractRunner( parent ),
m_networkAccessManager( new QNetworkAccessManager( this ) )
m_networkAccessManager( new QNetworkAccessManager( this ) ),
m_request()
{
connect( m_networkAccessManager, SIGNAL( finished( QNetworkReply * ) ),
this, SLOT( retrieveData( QNetworkReply * ) ) );
......@@ -81,18 +82,27 @@ void MapQuestRunner::retrieveRoute( const RouteRequest *route )
append( &url, "routeType", settings["preference"].toString() );
}
QNetworkReply *reply = m_networkAccessManager->get( QNetworkRequest( QUrl( url ) ) );
connect( reply, SIGNAL( error( QNetworkReply::NetworkError ) ),
this, SLOT( handleError( QNetworkReply::NetworkError ) ) );
m_request.setUrl( QUrl( url ) );
m_request.setRawHeader( "User-Agent", TinyWebBrowser::userAgent( "Browser", "MapQuestRunner" ) );
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();
}
void MapQuestRunner::get()
{
QNetworkReply *reply = m_networkAccessManager->get( m_request );
connect( reply, SIGNAL( error( QNetworkReply::NetworkError ) ),
this, SLOT( handleError( QNetworkReply::NetworkError ) ), Qt::DirectConnection );
}
void MapQuestRunner::retrieveData( QNetworkReply *reply )
{
if ( reply->isFinished() ) {
......
......@@ -39,6 +39,8 @@ public:
virtual void retrieveRoute( const RouteRequest *request );
private Q_SLOTS:
void get();
/** Route data was retrieved via http */
void retrieveData( QNetworkReply *reply );
......@@ -53,6 +55,8 @@ private:
GeoDataDocument* parse( const QByteArray &input ) const;
QNetworkAccessManager *m_networkAccessManager;
QNetworkRequest m_request;
};
}
......
Supports Markdown
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