Browse Source

main: Returning critical messsage and an error code when QGC is already running

Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
QGC4.4
Patrick José Pereira 6 years ago
parent
commit
680ad11195
  1. 8
      src/main.cc

8
src/main.cc

@ -19,6 +19,7 @@
#include <QApplication> #include <QApplication>
#include <QIcon> #include <QIcon>
#include <QSslSocket> #include <QSslSocket>
#include <QMessageBox>
#include <QProcessEnvironment> #include <QProcessEnvironment>
#include <QHostAddress> #include <QHostAddress>
#include <QUdpSocket> #include <QUdpSocket>
@ -222,7 +223,12 @@ int main(int argc, char *argv[])
#ifndef __mobile__ #ifndef __mobile__
RunGuard guard("QGroundControlRunGuardKey"); RunGuard guard("QGroundControlRunGuardKey");
if (!guard.tryToRun()) { if (!guard.tryToRun()) {
return 0; // QApplication is necessary to use QMessageBox
QApplication errorApp(argc, argv);
QMessageBox::critical(nullptr, QObject::tr("Error"),
QObject::tr("A second instance of QGroundControl is already running. Please close the other instance and try again.")
);
return -1;
} }
#endif #endif

Loading…
Cancel
Save