diff --git a/src/comm/QGCFlightGearLink.cc b/src/comm/QGCFlightGearLink.cc index e48c1d143f45eda49b9691c12613ec6e0c6b603f..198cf8dea0ffa2737c736ca6277bd68e2eb3693f 100644 --- a/src/comm/QGCFlightGearLink.cc +++ b/src/comm/QGCFlightGearLink.cc @@ -63,6 +63,9 @@ QGCFlightGearLink::QGCFlightGearLink(UASInterface* mav, QString startupArguments this->mav = mav; this->name = tr("FlightGear 3.0+ Link (port:%1)").arg(port); setRemoteHost(remoteHost); + + // We need a mechanism so show error message from our FGLink thread on the UI thread. This signal connection will do that for us. + connect(this, SIGNAL(showCriticalMessageFromThread(const QString&, const QString&)), MainWindow::instance(), SLOT(showCriticalMessage(const QString&, const QString&))); } QGCFlightGearLink::~QGCFlightGearLink() @@ -158,23 +161,23 @@ void QGCFlightGearLink::processError(QProcess::ProcessError err) switch(err) { case QProcess::FailedToStart: - MainWindow::instance()->showCriticalMessage(tr("FlightGear Failed to Start"), tr("Please check if the path and command is correct")); + emit showCriticalMessageFromThread(tr("FlightGear Failed to Start"), tr("Please check if the path and command is correct")); break; case QProcess::Crashed: - MainWindow::instance()->showCriticalMessage(tr("FlightGear Crashed"), tr("This is a FlightGear-related problem. Please upgrade FlightGear")); + emit showCriticalMessageFromThread(tr("FlightGear Crashed"), tr("This is a FlightGear-related problem. Please upgrade FlightGear")); break; case QProcess::Timedout: - MainWindow::instance()->showCriticalMessage(tr("FlightGear Start Timed Out"), tr("Please check if the path and command is correct")); + emit showCriticalMessageFromThread(tr("FlightGear Start Timed Out"), tr("Please check if the path and command is correct")); break; case QProcess::WriteError: - MainWindow::instance()->showCriticalMessage(tr("Could not Communicate with FlightGear"), tr("Please check if the path and command is correct")); + emit showCriticalMessageFromThread(tr("Could not Communicate with FlightGear"), tr("Please check if the path and command is correct")); break; case QProcess::ReadError: - MainWindow::instance()->showCriticalMessage(tr("Could not Communicate with FlightGear"), tr("Please check if the path and command is correct")); + emit showCriticalMessageFromThread(tr("Could not Communicate with FlightGear"), tr("Please check if the path and command is correct")); break; case QProcess::UnknownError: default: - MainWindow::instance()->showCriticalMessage(tr("FlightGear Error"), tr("Please check if the path and command is correct.")); + emit showCriticalMessageFromThread(tr("FlightGear Error"), tr("Please check if the path and command is correct.")); break; } } diff --git a/src/comm/QGCFlightGearLink.h b/src/comm/QGCFlightGearLink.h index 6f16a2f5d855bd82c6306d53f1f0e49fcc1558ea..02dc11b94c83abadd82d26fbe30f2bc5e9fcfd4a 100644 --- a/src/comm/QGCFlightGearLink.h +++ b/src/comm/QGCFlightGearLink.h @@ -91,6 +91,9 @@ public: static bool parseUIArguments(QString uiArgs, QStringList& argList); void run(); + +signals: + void showCriticalMessageFromThread(const QString& title, const QString& message); public slots: // void setAddress(QString address);