Commit f82b33a4 authored by oberion's avatar oberion

Deleting the MainWindow instance after closing application

Fixed some destructor commands
parent 259845de
...@@ -204,8 +204,9 @@ QGCCore::~QGCCore() ...@@ -204,8 +204,9 @@ QGCCore::~QGCCore()
{ {
//mainWindow->storeSettings(); //mainWindow->storeSettings();
mainWindow->close(); mainWindow->close();
mainWindow->deleteLater(); //mainWindow->deleteLater();
// Delete singletons // Delete singletons
delete MainWindow::instance();
delete LinkManager::instance(); delete LinkManager::instance();
delete UASManager::instance(); delete UASManager::instance();
} }
......
...@@ -50,8 +50,8 @@ HDDisplay::HDDisplay(QStringList* plotList, QString title, QWidget *parent) : ...@@ -50,8 +50,8 @@ HDDisplay::HDDisplay(QStringList* plotList, QString title, QWidget *parent) :
acceptUnitList(new QStringList()), acceptUnitList(new QStringList()),
lastPaintTime(0), lastPaintTime(0),
columns(3), columns(3),
valuesChanged(true)/*, valuesChanged(true),
m_ui(new Ui::HDDisplay)*/ m_ui(NULL)
{ {
setWindowTitle(title); setWindowTitle(title);
//m_ui->setupUi(this); //m_ui->setupUi(this);
...@@ -135,7 +135,22 @@ HDDisplay::HDDisplay(QStringList* plotList, QString title, QWidget *parent) : ...@@ -135,7 +135,22 @@ HDDisplay::HDDisplay(QStringList* plotList, QString title, QWidget *parent) :
HDDisplay::~HDDisplay() HDDisplay::~HDDisplay()
{ {
saveState(); saveState();
delete m_ui; if(this->refreshTimer)
{
delete this->refreshTimer;
}
if(this->acceptList)
{
delete this->acceptList;
}
if(this->acceptUnitList)
{
delete this->acceptUnitList;
}
if(this->m_ui)
{
delete m_ui;
}
} }
QSize HDDisplay::sizeHint() const QSize HDDisplay::sizeHint() const
......
...@@ -136,6 +136,11 @@ HSIDisplay::HSIDisplay(QWidget *parent) : ...@@ -136,6 +136,11 @@ HSIDisplay::HSIDisplay(QWidget *parent) :
setFocusPolicy(Qt::StrongFocus); setFocusPolicy(Qt::StrongFocus);
} }
HSIDisplay::~HSIDisplay()
{
}
void HSIDisplay::resetMAVState() void HSIDisplay::resetMAVState()
{ {
mavInitialized = false; mavInitialized = false;
......
...@@ -48,7 +48,7 @@ class HSIDisplay : public HDDisplay ...@@ -48,7 +48,7 @@ class HSIDisplay : public HDDisplay
Q_OBJECT Q_OBJECT
public: public:
HSIDisplay(QWidget *parent = 0); HSIDisplay(QWidget *parent = 0);
// ~HSIDisplay(); ~HSIDisplay();
public slots: public slots:
void setActiveUAS(UASInterface* uas); void setActiveUAS(UASInterface* uas);
......
...@@ -91,7 +91,7 @@ MainWindow::MainWindow(QWidget *parent): ...@@ -91,7 +91,7 @@ MainWindow::MainWindow(QWidget *parent):
currentStyle(QGC_MAINWINDOW_STYLE_INDOOR), currentStyle(QGC_MAINWINDOW_STYLE_INDOOR),
aboutToCloseFlag(false), aboutToCloseFlag(false),
changingViewsFlag(false), changingViewsFlag(false),
centerStackActionGroup(this), centerStackActionGroup(new QActionGroup(this)),
styleFileName(QCoreApplication::applicationDirPath() + "/style-indoor.css"), styleFileName(QCoreApplication::applicationDirPath() + "/style-indoor.css"),
autoReconnect(false), autoReconnect(false),
lowPowerMode(false) lowPowerMode(false)
...@@ -138,7 +138,7 @@ MainWindow::MainWindow(QWidget *parent): ...@@ -138,7 +138,7 @@ MainWindow::MainWindow(QWidget *parent):
setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea); setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
// Setup UI state machines // Setup UI state machines
centerStackActionGroup.setExclusive(true); centerStackActionGroup->setExclusive(true);
centerStack = new QStackedWidget(this); centerStack = new QStackedWidget(this);
setCentralWidget(centerStack); setCentralWidget(centerStack);
...@@ -246,8 +246,8 @@ MainWindow::~MainWindow() ...@@ -246,8 +246,8 @@ MainWindow::~MainWindow()
if (dockWidget) if (dockWidget)
{ {
// Remove dock widget from main window // Remove dock widget from main window
removeDockWidget(dockWidget); // removeDockWidget(dockWidget);
delete dockWidget->widget(); // delete dockWidget->widget();
delete dockWidget; delete dockWidget;
} }
else else
...@@ -417,14 +417,14 @@ void MainWindow::buildCommonWidgets() ...@@ -417,14 +417,14 @@ void MainWindow::buildCommonWidgets()
parametersDockWidget->setObjectName("PARAMETER_INTERFACE_DOCKWIDGET"); parametersDockWidget->setObjectName("PARAMETER_INTERFACE_DOCKWIDGET");
addTool(parametersDockWidget, tr("Calibration and Parameters"), Qt::RightDockWidgetArea); addTool(parametersDockWidget, tr("Calibration and Parameters"), Qt::RightDockWidgetArea);
} }
if (!hsiDockWidget) { if (!hsiDockWidget) {
hsiDockWidget = new QDockWidget(tr("Horizontal Situation Indicator"), this); hsiDockWidget = new QDockWidget(tr("Horizontal Situation Indicator"), this);
hsiDockWidget->setWidget( new HSIDisplay(this) ); hsiDockWidget->setWidget( new HSIDisplay(this) );
hsiDockWidget->setObjectName("HORIZONTAL_SITUATION_INDICATOR_DOCK_WIDGET"); hsiDockWidget->setObjectName("HORIZONTAL_SITUATION_INDICATOR_DOCK_WIDGET");
addTool(hsiDockWidget, tr("Horizontal Situation"), Qt::BottomDockWidgetArea); addTool(hsiDockWidget, tr("Horizontal Situation"), Qt::BottomDockWidgetArea);
} }
if (!headDown1DockWidget) { if (!headDown1DockWidget) {
headDown1DockWidget = new QDockWidget(tr("Flight Display"), this); headDown1DockWidget = new QDockWidget(tr("Flight Display"), this);
HDDisplay* hdDisplay = new HDDisplay(acceptList, "Flight Display", this); HDDisplay* hdDisplay = new HDDisplay(acceptList, "Flight Display", this);
...@@ -442,7 +442,7 @@ void MainWindow::buildCommonWidgets() ...@@ -442,7 +442,7 @@ void MainWindow::buildCommonWidgets()
headDown2DockWidget->setObjectName("HEAD_DOWN_DISPLAY_2_DOCK_WIDGET"); headDown2DockWidget->setObjectName("HEAD_DOWN_DISPLAY_2_DOCK_WIDGET");
addTool(headDown2DockWidget, tr("Actuator Status"), Qt::RightDockWidgetArea); addTool(headDown2DockWidget, tr("Actuator Status"), Qt::RightDockWidgetArea);
} }
if (!rcViewDockWidget) { if (!rcViewDockWidget) {
rcViewDockWidget = new QDockWidget(tr("Radio Control"), this); rcViewDockWidget = new QDockWidget(tr("Radio Control"), this);
rcViewDockWidget->setWidget( new QGCRemoteControlView(this) ); rcViewDockWidget->setWidget( new QGCRemoteControlView(this) );
...@@ -555,7 +555,7 @@ void MainWindow::addCentralWidget(QWidget* widget, const QString& title) ...@@ -555,7 +555,7 @@ void MainWindow::addCentralWidget(QWidget* widget, const QString& title)
QVariant var; QVariant var;
var.setValue((QWidget*)widget); var.setValue((QWidget*)widget);
tempAction->setData(var); tempAction->setData(var);
centerStackActionGroup.addAction(tempAction); centerStackActionGroup->addAction(tempAction);
connect(tempAction,SIGNAL(triggered()),this, SLOT(showCentralWidget())); connect(tempAction,SIGNAL(triggered()),this, SLOT(showCentralWidget()));
connect(widget, SIGNAL(visibilityChanged(bool)), tempAction, SLOT(setChecked(bool))); connect(widget, SIGNAL(visibilityChanged(bool)), tempAction, SLOT(setChecked(bool)));
tempAction->setChecked(widget->isVisible()); tempAction->setChecked(widget->isVisible());
......
...@@ -303,7 +303,7 @@ protected: ...@@ -303,7 +303,7 @@ protected:
QSettings settings; QSettings settings;
QStackedWidget *centerStack; QStackedWidget *centerStack;
QActionGroup centerStackActionGroup; QActionGroup* centerStackActionGroup;
// Center widgets // Center widgets
QPointer<Linecharts> linechartWidget; QPointer<Linecharts> linechartWidget;
......
...@@ -43,8 +43,8 @@ QGCRemoteControlView::QGCRemoteControlView(QWidget *parent) : ...@@ -43,8 +43,8 @@ QGCRemoteControlView::QGCRemoteControlView(QWidget *parent) :
uasId(-1), uasId(-1),
rssi(0.0f), rssi(0.0f),
updated(false), updated(false),
channelLayout(new QVBoxLayout())//, channelLayout(new QVBoxLayout()),
//ui(new Ui::QGCRemoteControlView) ui(NULL)
{ {
ui->setupUi(this); ui->setupUi(this);
QGridLayout* layout = new QGridLayout(this); QGridLayout* layout = new QGridLayout(this);
...@@ -71,8 +71,14 @@ QGCRemoteControlView::QGCRemoteControlView(QWidget *parent) : ...@@ -71,8 +71,14 @@ QGCRemoteControlView::QGCRemoteControlView(QWidget *parent) :
QGCRemoteControlView::~QGCRemoteControlView() QGCRemoteControlView::~QGCRemoteControlView()
{ {
delete ui; if(this->ui)
delete channelLayout; {
delete ui;
}
if(this->channelLayout)
{
delete channelLayout;
}
} }
void QGCRemoteControlView::setUASId(int id) void QGCRemoteControlView::setUASId(int id)
...@@ -172,7 +178,7 @@ void QGCRemoteControlView::setRemoteRSSI(float rssiNormalized) ...@@ -172,7 +178,7 @@ void QGCRemoteControlView::setRemoteRSSI(float rssiNormalized)
void QGCRemoteControlView::appendChannelWidget(int channelId) void QGCRemoteControlView::appendChannelWidget(int channelId)
{ {
// Create new layout // Create new layout
QHBoxLayout* layout = new QHBoxLayout(); QHBoxLayout* layout = new QHBoxLayout(this);
// Add content // Add content
layout->addWidget(new QLabel(QString("Channel %1").arg(channelId + 1), this)); layout->addWidget(new QLabel(QString("Channel %1").arg(channelId + 1), this));
QLabel* raw = new QLabel(this); QLabel* raw = new QLabel(this);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment