Skip to content

Commit

Permalink
main: fix Ctrl+C
Browse files Browse the repository at this point in the history
This avoids a segfault on destruction when no vehicle was ever
discovered.

Signed-off-by: Julian Oes <julian@oes.ch>
  • Loading branch information
julianoes committed Apr 11, 2024
1 parent b88616a commit 5fdb6a2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/QGCApplication.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 5 additions & 1 deletion src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <QUdpSocket>
#include <QtPlugin>
#include <QStringListModel>
#include <QQuickStyle>
#include <QQuickWindow>

#include "QGC.h"
#include "QGCApplication.h"
Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit 5fdb6a2

Please sign in to comment.