Browse Source

main: fix Ctrl+C

This avoids a segfault on destruction when no vehicle was ever
discovered.

Signed-off-by: Julian Oes <julian@oes.ch>
QGC4.4
Julian Oes 1 year ago
parent
commit
5fdb6a2e55
No known key found for this signature in database
GPG Key ID: F0ED380FEA56DE41
  1. 2
      src/QGCApplication.cc
  2. 6
      src/main.cc

2
src/QGCApplication.cc

@ -1017,7 +1017,7 @@ bool QGCApplication::compressEvent(QEvent*event, QObject* receiver, QPostEventLi @@ -1017,7 +1017,7 @@ bool QGCApplication::compressEvent(QEvent*event, QObject* receiver, QPostEventLi
bool QGCApplication::event(QEvent *e)
{
if (e->type() == QEvent::Quit) {
// On OSX if the user selects Quit from the menu (or Command-Q) the ApplicationWindow does not signal closing. Instead you get a Quit even here only.
// On OSX if the user selects Quit from the menu (or Command-Q) the ApplicationWindow does not signal closing. Instead you get a Quit event here only.
// This in turn causes the standard QGC shutdown sequence to not run. So in this case we close the window ourselves such that the
// signal is sent and the normal shutdown sequence runs.
bool forceClose = _mainRootWindow->property("_forceClose").toBool();

6
src/main.cc

@ -17,6 +17,8 @@ @@ -17,6 +17,8 @@
#include <QUdpSocket>
#include <QtPlugin>
#include <QStringListModel>
#include <QQuickStyle>
#include <QQuickWindow>
#include "QGC.h"
#include "QGCApplication.h"
@ -221,7 +223,9 @@ bool checkAndroidWritePermission() { @@ -221,7 +223,9 @@ bool checkAndroidWritePermission() {
void sigHandler(int s)
{
std::signal(s, SIG_DFL);
QApplication::instance()->quit();
qgcApp()->mainRootWindow()->close();
QEvent event{QEvent::Quit};
qgcApp()->event(&event);
}
#endif /* Q_OS_LINUX */

Loading…
Cancel
Save