Browse Source

Fix shutdown on OSX

fix
Fix
QGC4.4
Don Gagne 4 years ago committed by Don Gagne
parent
commit
dbd12d40a4
  1. 27
      src/QGCApplication.cc
  2. 6
      src/QGCApplication.h
  3. 3
      src/VideoManager/VideoManager.cc

27
src/QGCApplication.cc

@ -553,7 +553,7 @@ bool QGCApplication::_initForNormalAppBoot() @@ -553,7 +553,7 @@ bool QGCApplication::_initForNormalAppBoot()
QQuickImageProvider* pImgProvider = dynamic_cast<QQuickImageProvider*>(qgcApp()->toolbox()->imageProvider());
_qmlAppEngine->addImageProvider(QStringLiteral("QGCImages"), pImgProvider);
QQuickWindow* rootWindow = (QQuickWindow*)qgcApp()->mainRootWindow();
QQuickWindow* rootWindow = qgcApp()->mainRootWindow();
if (rootWindow) {
rootWindow->scheduleRenderJob (new FinishVideoInitialization (toolbox()->videoManager()),
@ -788,10 +788,10 @@ void QGCApplication::_showDelayedAppMessages(void) @@ -788,10 +788,10 @@ void QGCApplication::_showDelayedAppMessages(void)
}
}
QQuickItem* QGCApplication::mainRootWindow()
QQuickWindow* QGCApplication::mainRootWindow()
{
if(!_mainRootWindow) {
_mainRootWindow = reinterpret_cast<QQuickItem*>(_rootQmlObject());
_mainRootWindow = qobject_cast<QQuickWindow*>(_rootQmlObject());
}
return _mainRootWindow;
}
@ -1014,3 +1014,24 @@ bool QGCApplication::compressEvent(QEvent*event, QObject* receiver, QPostEventLi @@ -1014,3 +1014,24 @@ bool QGCApplication::compressEvent(QEvent*event, QObject* receiver, QPostEventLi
return false;
}
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.
// 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();
qDebug() << "Quit event" << forceClose;
// forceClose
// true: Standard QGC shutdown sequence is complete. Let the app quit normally by falling through to the base class processing.
// false: QGC shutdown sequence has not been run yet. Don't let this event close the app yet. Close the main window to kick off the normal shutdown.
if (!forceClose) {
//
_mainRootWindow->close();
e->ignore();
return true;
}
}
return QApplication::event(e);
}

6
src/QGCApplication.h

@ -93,7 +93,7 @@ public: @@ -93,7 +93,7 @@ public:
QTranslator& qgcJSONTranslator(void) { return _qgcTranslatorJSON; }
void setLanguage();
QQuickItem* mainRootWindow();
QQuickWindow* mainRootWindow();
uint64_t msecsSinceBoot(void) { return _msecsElapsedTime.elapsed(); }
/// Registers the signal such that only the last duplicate signal added is left in the queue.
@ -101,6 +101,8 @@ public: @@ -101,6 +101,8 @@ public:
void removeCompressedSignal(const QMetaMethod & method);
bool event(QEvent *e) override;
static QString cachedParameterMetaDataFile(void);
static QString cachedAirframeMetaDataFile(void);
@ -203,7 +205,7 @@ private: @@ -203,7 +205,7 @@ private:
int _buildVersion = 0;
GPSRTKFactGroup* _gpsRtkFactGroup = nullptr;
QGCToolbox* _toolbox = nullptr;
QQuickItem* _mainRootWindow = nullptr;
QQuickWindow* _mainRootWindow = nullptr;
bool _bluetoothAvailable = false;
QTranslator _qgcTranslatorSourceCode; ///< translations for source code C++/Qml
QTranslator _qgcTranslatorJSON; ///< translations for json files

3
src/VideoManager/VideoManager.cc

@ -13,6 +13,7 @@ @@ -13,6 +13,7 @@
#include <QSettings>
#include <QUrl>
#include <QDir>
#include <QQuickWindow>
#ifndef QGC_DISABLE_UVC
#include <QCameraInfo>
@ -569,7 +570,7 @@ void @@ -569,7 +570,7 @@ void
VideoManager::_initVideo()
{
#if defined(QGC_GST_STREAMING)
QQuickItem* root = qgcApp()->mainRootWindow();
QQuickWindow* root = qgcApp()->mainRootWindow();
if (root == nullptr) {
qCDebug(VideoManagerLog) << "mainRootWindow() failed. No root window";

Loading…
Cancel
Save