|
|
@ -135,6 +135,7 @@ MainWindow::MainWindow() |
|
|
|
: _lowPowerMode(false) |
|
|
|
: _lowPowerMode(false) |
|
|
|
, _showStatusBar(false) |
|
|
|
, _showStatusBar(false) |
|
|
|
, _mainQmlWidgetHolder(NULL) |
|
|
|
, _mainQmlWidgetHolder(NULL) |
|
|
|
|
|
|
|
, _forceClose(false) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Q_ASSERT(_instance == NULL); |
|
|
|
Q_ASSERT(_instance == NULL); |
|
|
|
_instance = this; |
|
|
|
_instance = this; |
|
|
@ -161,6 +162,7 @@ MainWindow::MainWindow() |
|
|
|
_centralLayout->addWidget(_mainQmlWidgetHolder); |
|
|
|
_centralLayout->addWidget(_mainQmlWidgetHolder); |
|
|
|
_mainQmlWidgetHolder->setVisible(true); |
|
|
|
_mainQmlWidgetHolder->setVisible(true); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership); |
|
|
|
_mainQmlWidgetHolder->setContextPropertyObject("controller", this); |
|
|
|
_mainQmlWidgetHolder->setContextPropertyObject("controller", this); |
|
|
|
_mainQmlWidgetHolder->setSource(QUrl::fromUserInput("qrc:qml/MainWindowHybrid.qml")); |
|
|
|
_mainQmlWidgetHolder->setSource(QUrl::fromUserInput("qrc:qml/MainWindowHybrid.qml")); |
|
|
|
|
|
|
|
|
|
|
@ -408,56 +410,29 @@ void MainWindow::showStatusBarCallback(bool checked) |
|
|
|
checked ? statusBar()->show() : statusBar()->hide(); |
|
|
|
checked ? statusBar()->show() : statusBar()->hide(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::acceptWindowClose(void) |
|
|
|
void MainWindow::reallyClose(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
qgcApp()->toolbox()->linkManager()->shutdown(); |
|
|
|
_forceClose = true; |
|
|
|
// The above shutdown causes a flurry of activity as the vehicle components are removed. This in turn
|
|
|
|
close(); |
|
|
|
// causes the Windows Version of Qt to crash if you allow the close event to be accepted. In order to prevent
|
|
|
|
|
|
|
|
// the crash, we ignore the close event and setup a delayed timer to close the window after things settle down.
|
|
|
|
|
|
|
|
QTimer::singleShot(1500, this, &MainWindow::_closeWindow); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::closeEvent(QCloseEvent *event) |
|
|
|
void MainWindow::closeEvent(QCloseEvent *event) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Disallow window close if there are active connections
|
|
|
|
if (!_forceClose) { |
|
|
|
if (qgcApp()->toolbox()->multiVehicleManager()->vehicles()->count()) { |
|
|
|
// Attemp close from within the root Qml item
|
|
|
|
qgcApp()->showWindowCloseMessage(); |
|
|
|
qgcApp()->qmlAttemptWindowClose(); |
|
|
|
event->ignore(); |
|
|
|
event->ignore(); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// We still need to shutdown LinkManager even though no active connections so that we don't get any
|
|
|
|
|
|
|
|
// more auto-connect links during shutdown.
|
|
|
|
|
|
|
|
qgcApp()->toolbox()->linkManager()->shutdown(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// This will process any remaining flight log save dialogs
|
|
|
|
|
|
|
|
qgcApp()->processEvents(QEventLoop::ExcludeUserInputEvents); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Should not be any active connections
|
|
|
|
// Should not be any active connections
|
|
|
|
if (qgcApp()->toolbox()->linkManager()->anyActiveLinks()) { |
|
|
|
if (qgcApp()->toolbox()->linkManager()->anyActiveLinks()) { |
|
|
|
qWarning() << "All links should be disconnected by now"; |
|
|
|
qWarning() << "All links should be disconnected by now"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// We have to pull out the QmlWidget from the main window and delete it here, before
|
|
|
|
|
|
|
|
// the MainWindow ends up getting deleted. Otherwise the Qml has a reference to MainWindow
|
|
|
|
|
|
|
|
// inside it which in turn causes a shutdown crash.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-- Unit test gets here with _mainQmlWidgetHolder being NULL
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(_mainQmlWidgetHolder) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Remove image provider
|
|
|
|
|
|
|
|
_mainQmlWidgetHolder->getEngine()->removeImageProvider(QLatin1String("QGCImages")); |
|
|
|
|
|
|
|
_centralLayout->removeWidget(_mainQmlWidgetHolder); |
|
|
|
|
|
|
|
delete _mainQmlWidgetHolder; |
|
|
|
|
|
|
|
_mainQmlWidgetHolder = NULL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_storeCurrentViewState(); |
|
|
|
_storeCurrentViewState(); |
|
|
|
storeSettings(); |
|
|
|
storeSettings(); |
|
|
|
|
|
|
|
|
|
|
|
event->accept(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-- TODO: This effectively causes the QGCApplication destructor to not being able
|
|
|
|
//-- TODO: This effectively causes the QGCApplication destructor to not being able
|
|
|
|
// to access the pointer it is trying to delete.
|
|
|
|
// to access the pointer it is trying to delete.
|
|
|
|
_instance = NULL; |
|
|
|
_instance = NULL; |
|
|
|