diff options
Diffstat (limited to 'src/plugins')
5 files changed, 19 insertions, 4 deletions
diff --git a/src/plugins/position/simulator/qgeopositioninfosourcefactory_simulator.cpp b/src/plugins/position/simulator/qgeopositioninfosourcefactory_simulator.cpp index 07256588..8f1b7974 100644 --- a/src/plugins/position/simulator/qgeopositioninfosourcefactory_simulator.cpp +++ b/src/plugins/position/simulator/qgeopositioninfosourcefactory_simulator.cpp @@ -48,5 +48,10 @@ QGeoPositionInfoSource *QGeoPositionInfoSourceFactorySimulator::positionInfoSour QGeoSatelliteInfoSource *QGeoPositionInfoSourceFactorySimulator::satelliteInfoSource(QObject *parent) { - return new QGeoSatelliteInfoSourceSimulator(parent); + QGeoSatelliteInfoSourceSimulator *src = new QGeoSatelliteInfoSourceSimulator(parent); + if (!src->isConnected()) { + delete src; + src = 0; + } + return src; } diff --git a/src/plugins/position/simulator/qgeosatelliteinfosource_simulator.cpp b/src/plugins/position/simulator/qgeosatelliteinfosource_simulator.cpp index 6840f55e..d822c80a 100644 --- a/src/plugins/position/simulator/qgeosatelliteinfosource_simulator.cpp +++ b/src/plugins/position/simulator/qgeosatelliteinfosource_simulator.cpp @@ -57,6 +57,11 @@ QGeoSatelliteInfoSourceSimulator::QGeoSatelliteInfoSourceSimulator(QObject *pare connect(requestTimer, SIGNAL(timeout()), this, SLOT(updateData())); } +bool QGeoSatelliteInfoSourceSimulator::isConnected() const +{ + return Simulator::LocationConnection::ensureSimulatorConnection(); +} + void QGeoSatelliteInfoSourceSimulator::startUpdates() { int interval = updateInterval(); diff --git a/src/plugins/position/simulator/qgeosatelliteinfosource_simulator_p.h b/src/plugins/position/simulator/qgeosatelliteinfosource_simulator_p.h index 0d76a375..ce12c191 100644 --- a/src/plugins/position/simulator/qgeosatelliteinfosource_simulator_p.h +++ b/src/plugins/position/simulator/qgeosatelliteinfosource_simulator_p.h @@ -60,6 +60,8 @@ class QGeoSatelliteInfoSourceSimulator : public QGeoSatelliteInfoSource public: explicit QGeoSatelliteInfoSourceSimulator(QObject *parent = 0); + bool isConnected() const; + virtual void setUpdateInterval(int msec); virtual int minimumUpdateInterval() const; diff --git a/src/plugins/position/simulator/qlocationconnection_simulator.cpp b/src/plugins/position/simulator/qlocationconnection_simulator.cpp index a35419e1..4f530e41 100644 --- a/src/plugins/position/simulator/qlocationconnection_simulator.cpp +++ b/src/plugins/position/simulator/qlocationconnection_simulator.cpp @@ -67,7 +67,8 @@ namespace Simulator qt_registerLocationTypes(); mWorker = mConnection->connectToServer(Connection::simulatorHostName(true), simulatorPort); if (!mWorker) - qFatal("Could not connect to server"); + return; + mWorker->addReceiver(this); // register for location notifications @@ -85,9 +86,10 @@ namespace Simulator delete mConnection; } - void LocationConnection::ensureSimulatorConnection() + bool LocationConnection::ensureSimulatorConnection() { static LocationConnection locationConnection; + return locationConnection.mWorker; } void LocationConnection::initialLocationDataSent() diff --git a/src/plugins/position/simulator/qlocationconnection_simulator_p.h b/src/plugins/position/simulator/qlocationconnection_simulator_p.h index 22cc3b63..dc0739bc 100644 --- a/src/plugins/position/simulator/qlocationconnection_simulator_p.h +++ b/src/plugins/position/simulator/qlocationconnection_simulator_p.h @@ -57,8 +57,9 @@ namespace Simulator class LocationConnection : public QObject { Q_OBJECT + public: - static void ensureSimulatorConnection(); + static bool ensureSimulatorConnection(); virtual ~LocationConnection(); private: |