Commit 54dbcdd9 authored by Bernhard Beschow's avatar Bernhard Beschow
Browse files

instantiate runners in the GUI thread

This should finally privide a workaround for QTBUG-15004.
Networked plugins seem to work on the desktop under Qt 4.8.4, under Harmattan with Qt 4.7.4(?) and on Maemo 5 with the buggy Qt 4.7.0.

BUG: 257376
parent 2ff41793
......@@ -212,7 +212,7 @@ void MarbleRunnerManager::findPlacemarks( const QString &searchTerm, const GeoDa
QList<const SearchRunnerPlugin*> plugins = d->plugins( d->m_pluginManager->searchRunnerPlugins() );
foreach( const SearchRunnerPlugin* plugin, plugins ) {
SearchTask* task = new SearchTask( plugin, this, d->m_marbleModel, searchTerm, preferred );
SearchTask* task = new SearchTask( plugin->newRunner(), this, d->m_marbleModel, searchTerm, preferred );
connect( task, SIGNAL( finished( RunnerTask* ) ), this, SLOT( cleanupSearchTask( RunnerTask* ) ) );
d->m_searchTasks << task;
mDebug() << "search task " << plugin->nameId() << " " << (long)task;
......@@ -281,7 +281,7 @@ void MarbleRunnerManager::reverseGeocoding( const GeoDataCoordinates &coordinate
d->m_reverseGeocodingResults.removeAll( coordinates );
QList<const ReverseGeocodingRunnerPlugin*> plugins = d->plugins( d->m_pluginManager->reverseGeocodingRunnerPlugins() );
foreach( const ReverseGeocodingRunnerPlugin* plugin, plugins ) {
ReverseGeocodingTask* task = new ReverseGeocodingTask( plugin, this, d->m_marbleModel, coordinates );
ReverseGeocodingTask* task = new ReverseGeocodingTask( plugin->newRunner(), this, d->m_marbleModel, coordinates );
connect( task, SIGNAL( finished( RunnerTask* ) ), this, SLOT( cleanupReverseGeocodingTask(RunnerTask*) ) );
mDebug() << "reverse task " << plugin->nameId() << " " << (long)task;
d->m_reverseTasks << task;
......@@ -335,7 +335,7 @@ void MarbleRunnerManager::retrieveRoute( const RouteRequest *request )
continue;
}
RoutingTask* task = new RoutingTask( plugin, this, d->m_marbleModel, request );
RoutingTask* task = new RoutingTask( plugin->newRunner(), this, d->m_marbleModel, request );
connect( task, SIGNAL( finished( RunnerTask* ) ), this, SLOT( cleanupRoutingTask( RunnerTask* ) ) );
mDebug() << "route task " << plugin->nameId() << " " << (long)task;
d->m_routingTasks << task;
......@@ -383,7 +383,7 @@ void MarbleRunnerManager::parseFile( const QString &fileName, DocumentRole role
foreach( const ParseRunnerPlugin *plugin, plugins ) {
QStringList const extensions = plugin->fileExtensions();
if ( extensions.isEmpty() || extensions.contains( suffix ) || extensions.contains( completeSuffix ) ) {
ParsingTask *task = new ParsingTask( plugin, this, fileName, role );
ParsingTask *task = new ParsingTask( plugin->newRunner(), this, fileName, role );
connect( task, SIGNAL( finished( RunnerTask* ) ), this, SLOT( cleanupParsingTask(RunnerTask*) ) );
mDebug() << "parse task " << plugin->nameId() << " " << (long)task;
parsingTasks << task;
......
......@@ -13,10 +13,6 @@
#include "MarbleAbstractRunner.h"
#include "MarbleDebug.h"
#include "MarbleRunnerManager.h"
#include "ParseRunnerPlugin.h"
#include "ReverseGeocodingRunnerPlugin.h"
#include "RoutingRunnerPlugin.h"
#include "SearchRunnerPlugin.h"
#include "routing/RouteRequest.h"
#include <QtCore/QTimer>
......@@ -42,80 +38,69 @@ MarbleRunnerManager *RunnerTask::manager()
return m_manager;
}
SearchTask::SearchTask( const SearchRunnerPlugin* factory, MarbleRunnerManager *manager, MarbleModel *model, const QString &searchTerm, const GeoDataLatLonAltBox &preferred ) :
SearchTask::SearchTask( MarbleAbstractRunner *runner, MarbleRunnerManager *manager, MarbleModel *model, const QString &searchTerm, const GeoDataLatLonAltBox &preferred ) :
RunnerTask( manager ),
m_factory( factory ),
m_model( model ),
m_runner( runner ),
m_searchTerm( searchTerm ),
m_preferredBbox( preferred )
{
// nothing to do
connect( m_runner, SIGNAL( searchFinished( QVector<GeoDataPlacemark*> ) ),
manager, SLOT( addSearchResult( QVector<GeoDataPlacemark*> ) ) );
m_runner->setModel( model );
}
void SearchTask::runTask()
{
MarbleAbstractRunner *runner = m_factory->newRunner();
connect( runner, SIGNAL( searchFinished( QVector<GeoDataPlacemark*> ) ),
manager(), SLOT( addSearchResult( QVector<GeoDataPlacemark*> ) ) );
runner->setModel( m_model );
runner->search( m_searchTerm, m_preferredBbox );
runner->deleteLater();
m_runner->search( m_searchTerm, m_preferredBbox );
m_runner->deleteLater();
}
ReverseGeocodingTask::ReverseGeocodingTask( const ReverseGeocodingRunnerPlugin* factory, MarbleRunnerManager *manager, MarbleModel *model, const GeoDataCoordinates &coordinates ) :
ReverseGeocodingTask::ReverseGeocodingTask( MarbleAbstractRunner *runner, MarbleRunnerManager *manager, MarbleModel *model, const GeoDataCoordinates &coordinates ) :
RunnerTask( manager ),
m_factory( factory ),
m_model( model ),
m_runner( runner ),
m_coordinates( coordinates )
{
// nothing to do
connect( m_runner, SIGNAL( reverseGeocodingFinished( GeoDataCoordinates, GeoDataPlacemark ) ),
manager, SLOT( addReverseGeocodingResult( GeoDataCoordinates, GeoDataPlacemark ) ) );
m_runner->setModel( model );
}
void ReverseGeocodingTask::runTask()
{
MarbleAbstractRunner *runner = m_factory->newRunner();
connect( runner, SIGNAL( reverseGeocodingFinished( GeoDataCoordinates, GeoDataPlacemark ) ),
manager(), SLOT( addReverseGeocodingResult( GeoDataCoordinates, GeoDataPlacemark ) ) );
runner->setModel( m_model );
runner->reverseGeocoding( m_coordinates );
runner->deleteLater();
m_runner->reverseGeocoding( m_coordinates );
m_runner->deleteLater();
}
RoutingTask::RoutingTask( RoutingRunnerPlugin* factory, MarbleRunnerManager *manager, MarbleModel *model, const RouteRequest* routeRequest ) :
RoutingTask::RoutingTask( MarbleAbstractRunner *runner, MarbleRunnerManager *manager, MarbleModel *model, const RouteRequest* routeRequest ) :
RunnerTask( manager ),
m_factory( factory ),
m_model( model ),
m_runner( runner ),
m_routeRequest( routeRequest )
{
// nothing to do
connect( m_runner, SIGNAL( routeCalculated( GeoDataDocument* ) ),
manager, SLOT( addRoutingResult( GeoDataDocument* ) ) );
m_runner->setModel( model );
}
void RoutingTask::runTask()
{
MarbleAbstractRunner *runner = m_factory->newRunner();
connect( runner, SIGNAL( routeCalculated( GeoDataDocument* ) ),
manager(), SLOT( addRoutingResult( GeoDataDocument* ) ) );
runner->setModel( m_model );
runner->retrieveRoute( m_routeRequest );
runner->deleteLater();
m_runner->retrieveRoute( m_routeRequest );
m_runner->deleteLater();
}
ParsingTask::ParsingTask( const ParseRunnerPlugin *factory, MarbleRunnerManager *manager, const QString& fileName, DocumentRole role ) :
ParsingTask::ParsingTask( MarbleAbstractRunner *runner, MarbleRunnerManager *manager, const QString& fileName, DocumentRole role ) :
RunnerTask( manager ),
m_factory( factory ),
m_runner( runner ),
m_fileName( fileName ),
m_role( role )
{
// nothing to do
connect( m_runner, SIGNAL( parsingFinished( GeoDataDocument*, QString ) ),
manager, SLOT( addParsingResult( GeoDataDocument*, QString ) ) );
}
void ParsingTask::runTask()
{
MarbleAbstractRunner *runner = m_factory->newRunner();
connect( runner, SIGNAL( parsingFinished( GeoDataDocument*, QString ) ),
manager(), SLOT( addParsingResult( GeoDataDocument*, QString ) ) );
runner->parseFile( m_fileName, m_role );
runner->deleteLater();
m_runner->parseFile( m_fileName, m_role );
m_runner->deleteLater();
}
}
......
......@@ -23,10 +23,6 @@ namespace Marble
class MarbleModel;
class RouteRequest;
class SearchRunnerPlugin;
class ReverseGeocodingRunnerPlugin;
class RoutingRunnerPlugin;
class ParseRunnerPlugin;
class MarbleAbstractRunner;
class MarbleRunnerManager;
......@@ -65,13 +61,12 @@ class SearchTask : public RunnerTask
Q_OBJECT
public:
SearchTask( const SearchRunnerPlugin *factory, MarbleRunnerManager *manager, MarbleModel *model, const QString &searchTerm, const GeoDataLatLonAltBox &preferred );
SearchTask( MarbleAbstractRunner *runner, MarbleRunnerManager *manager, MarbleModel *model, const QString &searchTerm, const GeoDataLatLonAltBox &preferred );
virtual void runTask();
private:
const SearchRunnerPlugin *const m_factory;
MarbleModel *const m_model;
MarbleAbstractRunner *const m_runner;
QString m_searchTerm;
GeoDataLatLonAltBox m_preferredBbox;
};
......@@ -82,13 +77,12 @@ class ReverseGeocodingTask : public RunnerTask
Q_OBJECT
public:
ReverseGeocodingTask( const ReverseGeocodingRunnerPlugin*factory, MarbleRunnerManager *manager, MarbleModel *model, const GeoDataCoordinates &coordinates );
ReverseGeocodingTask( MarbleAbstractRunner *runner, MarbleRunnerManager *manager, MarbleModel *model, const GeoDataCoordinates &coordinates );
virtual void runTask();
private:
const ReverseGeocodingRunnerPlugin *const m_factory;
MarbleModel *const m_model;
MarbleAbstractRunner *const m_runner;
GeoDataCoordinates m_coordinates;
};
......@@ -99,13 +93,12 @@ class RoutingTask : public RunnerTask
Q_OBJECT
public:
RoutingTask( RoutingRunnerPlugin *factory, MarbleRunnerManager *manager, MarbleModel *model, const RouteRequest* routeRequest );
RoutingTask( MarbleAbstractRunner *runner, MarbleRunnerManager *manager, MarbleModel *model, const RouteRequest* routeRequest );
virtual void runTask();
private:
RoutingRunnerPlugin *const m_factory;
MarbleModel *const m_model;
MarbleAbstractRunner *const m_runner;
const RouteRequest *const m_routeRequest;
};
......@@ -115,12 +108,12 @@ class ParsingTask : public RunnerTask
Q_OBJECT
public:
ParsingTask( const ParseRunnerPlugin* factory, MarbleRunnerManager *manager, const QString& fileName, DocumentRole role );
ParsingTask( MarbleAbstractRunner *runner, MarbleRunnerManager *manager, const QString& fileName, DocumentRole role );
virtual void runTask();
private:
const ParseRunnerPlugin *const m_factory;
MarbleAbstractRunner *const m_runner;
QString m_fileName;
DocumentRole m_role;
};
......
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