From cdcabe42c44c0dfe7eeb0c944b4f520d3a64c82d Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sun, 28 Jul 2013 11:35:05 +0200 Subject: [PATCH] Revert "No longer automatically connect UDP on startup. Also removed some dead code" This reverts commit e003dd7a7c95c3e86704de14189ea2ea094712d7. --- src/QGCCore.cc | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/QGCCore.cc b/src/QGCCore.cc index 687af4f55..4fe7e4bae 100644 --- a/src/QGCCore.cc +++ b/src/QGCCore.cc @@ -147,6 +147,9 @@ QGCCore::QGCCore(int &argc, char* argv[]) : QApplication(argc, argv) // first messages arrive UDPLink* udpLink = new UDPLink(QHostAddress::Any, 14550); MainWindow::instance()->addLink(udpLink); + // Listen on Multicast-Address 239.255.77.77, Port 14550 + //QHostAddress * multicast_udp = new QHostAddress("239.255.77.77"); + //UDPLink* udpLink = new UDPLink(*multicast_udp, 14550); #ifdef OPAL_RT // Add OpalRT Link, but do not connect @@ -160,6 +163,37 @@ QGCCore::QGCCore(int &argc, char* argv[]) : QApplication(argc, argv) splashScreen->finish(mainWindow); if (upgraded) mainWindow->showInfoMessage(tr("Default Settings Loaded"), tr("QGroundControl has been upgraded from version %1 to version %2. Some of your user preferences have been reset to defaults for safety reasons. Please adjust them where needed.").arg(lastApplicationVersion).arg(QGC_APPLICATION_VERSION)); + + // Check if link could be connected + if (!udpLink->connect()) + { + QMessageBox msgBox; + msgBox.setIcon(QMessageBox::Critical); + msgBox.setText("Could not connect UDP port. Is an instance of " + qAppName() + "already running?"); + msgBox.setInformativeText("You will not be able to receive data via UDP. Please check that you're running the right executable and then re-start " + qAppName() + ". Do you want to close the application?"); + msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + msgBox.setDefaultButton(QMessageBox::No); + int ret = msgBox.exec(); + + // Close the message box shortly after the click to prevent accidental clicks + QTimer::singleShot(15000, &msgBox, SLOT(reject())); + + // Exit application + if (ret == QMessageBox::Yes) + { + //mainWindow->close(); + QTimer::singleShot(200, mainWindow, SLOT(close())); + } + } + +// forever +// { +// QGC::SLEEP::msleep(5000); +// } + +// mainWindow->close(); +// mainWindow->deleteLater(); +// QGC::SLEEP::msleep(200); } /** -- 2.22.0