diff --git a/src/QGCCore.cc b/src/QGCCore.cc index bee9f20268017887ced9878ca848bcc1414b71a0..d6d7e512a742c36aa9354892723a535cb9de6d91 100644 --- a/src/QGCCore.cc +++ b/src/QGCCore.cc @@ -203,7 +203,7 @@ QGCCore::QGCCore(int &argc, char* argv[]) : QApplication(argc, argv) QGCCore::~QGCCore() { //mainWindow->storeSettings(); - mainWindow->close(); + //mainWindow->close(); //mainWindow->deleteLater(); // Delete singletons // First systems @@ -211,7 +211,8 @@ QGCCore::~QGCCore() // then links delete LinkManager::instance(); // Finally the main window - delete MainWindow::instance(); + //delete MainWindow::instance(); + //The main window now autodeletes on close. } /** diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index 3eb6a33360155dffbb48e987108d6cb446c1ad9a..abddfc644f8d06bdbf45828faa4d917cf14f50b6 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -106,6 +106,7 @@ MainWindow::MainWindow(QWidget *parent): autoReconnect(false), lowPowerMode(false) { + this->setAttribute(Qt::WA_DeleteOnClose); hide(); dockWidgetTitleBarEnabled = true; isAdvancedMode = false; @@ -323,6 +324,16 @@ MainWindow::~MainWindow() } } // Delete all UAS objects + + + if (debugConsole) + { + delete debugConsole; + } + for (int i=0;ideleteLater(); + } } void MainWindow::resizeEvent(QResizeEvent * event) @@ -523,10 +534,17 @@ void MainWindow::buildCommonWidgets() connect(tempAction,SIGNAL(triggered(bool)),this, SLOT(showTool(bool))); } { - QAction* tempAction = ui.menuTools->addAction(tr("Communication Console")); - menuToDockNameMap[tempAction] = "COMMUNICATION_DEBUG_CONSOLE_DOCKWIDGET"; - tempAction->setCheckable(true); - connect(tempAction,SIGNAL(triggered(bool)),this, SLOT(showTool(bool))); + if (!debugConsole) + { + debugConsole = new DebugConsole(); + debugConsole->setWindowTitle("Communications Console"); + debugConsole->show(); + QAction* tempAction = ui.menuTools->addAction(tr("Communication Console")); + //menuToDockNameMap[tempAction] = "COMMUNICATION_DEBUG_CONSOLE_DOCKWIDGET"; + tempAction->setCheckable(true); + connect(tempAction,SIGNAL(triggered(bool)),debugConsole,SLOT(setShown(bool))); + + } } createDockWidget(simView,new HSIDisplay(this),tr("Horizontal Situation"),"HORIZONTAL_SITUATION_INDICATOR_DOCKWIDGET",VIEW_SIMULATION,Qt::BottomDockWidgetArea); @@ -772,7 +790,9 @@ void MainWindow::loadDockWidget(QString name) } else if (name == "COMMUNICATION_DEBUG_CONSOLE_DOCKWIDGET") { - createDockWidget(centerStack->currentWidget(),new DebugConsole(this),tr("Communication Console"),"COMMUNICATION_DEBUG_CONSOLE_DOCKWIDGET",currentView,Qt::BottomDockWidgetArea); + //This is now a permanently detached window. + //centralWidgetToDockWidgetsMap[currentView][name] = console; + //createDockWidget(centerStack->currentWidget(),new DebugConsole(this),tr("Communication Console"),"COMMUNICATION_DEBUG_CONSOLE_DOCKWIDGET",currentView,Qt::BottomDockWidgetArea); } else if (name == "HORIZONTAL_SITUATION_INDICATOR_DOCKWIDGET") { @@ -1614,6 +1634,8 @@ void MainWindow::addLink(LinkInterface *link) if (!found) { // || udp CommConfigurationWindow* commWidget = new CommConfigurationWindow(link, mavlink, this); + commsWidgetList.append(commWidget); + connect(commWidget,SIGNAL(destroyed(QObject*)),this,SLOT(commsWidgetDestroyed(QObject*))); QAction* action = commWidget->getAction(); ui.menuNetwork->addAction(action); @@ -1627,6 +1649,13 @@ void MainWindow::addLink(LinkInterface *link) } } } +void MainWindow::commsWidgetDestroyed(QObject *obj) +{ + if (commsWidgetList.contains(obj)) + { + commsWidgetList.removeOne(obj); + } +} void MainWindow::setActiveUAS(UASInterface* uas) { diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h index 4794f86ada79d2673f38d541d58dfba9030375f4..f9b322961e7689f0b21c5789215805591eee4ff7 100644 --- a/src/ui/MainWindow.h +++ b/src/ui/MainWindow.h @@ -250,6 +250,8 @@ public slots: /** @brief Update the window name */ void configureWindowName(); + void commsWidgetDestroyed(QObject *obj); + signals: void initStatusChanged(const QString& message); #ifdef MOUSE_ENABLED_LINUX @@ -397,6 +399,8 @@ protected: QPointer toolBar; QPointer customStatusBar; + QPointer debugConsole; + QPointer mavlinkInspectorWidget; QPointer mavlinkDecoder; QPointer mavlinkSenderWidget; @@ -441,6 +445,7 @@ protected: QTimer windowNameUpdateTimer; private: + QList commsWidgetList; QMap customWidgetNameToFilenameMap; QMap menuToDockNameMap; QMap dockToTitleBarMap;