From 7eea8ca3653d6913299fee23926325791d7ca25d Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Mon, 12 May 2014 05:04:34 +1000 Subject: [PATCH] Shut down GraphView tabs a little more cleanly --- sleepyhead/daily.cpp | 16 ++++++++++++---- sleepyhead/daily.h | 2 ++ sleepyhead/mainwindow.cpp | 9 ++++++--- sleepyhead/overview.cpp | 12 +++++++++--- sleepyhead/overview.h | 1 + sleepyhead/oximetry.cpp | 8 +++++++- sleepyhead/oximetry.h | 1 + 7 files changed, 38 insertions(+), 11 deletions(-) diff --git a/sleepyhead/daily.cpp b/sleepyhead/daily.cpp index 63248dc6..9b1b26ab 100644 --- a/sleepyhead/daily.cpp +++ b/sleepyhead/daily.cpp @@ -396,15 +396,12 @@ Daily::Daily(QWidget *parent,gGraphView * shared) previous_date=QDate(); } + Daily::~Daily() { - GraphView->SaveSettings("Daily"); // disconnect(sessbar, SIGNAL(toggledSession(Session*)), this, SLOT(doToggleSession(Session*))); - disconnect(webView,SIGNAL(linkClicked(QUrl)),this,SLOT(Link_clicked(QUrl))); // Save any last minute changes.. - if (previous_date.isValid()) - Unload(previous_date); // delete splitter; delete ui; @@ -412,6 +409,17 @@ Daily::~Daily() delete icon_off; } +void Daily::closeEvent(QCloseEvent *event) +{ + disconnect(webView,SIGNAL(linkClicked(QUrl)),this,SLOT(Link_clicked(QUrl))); + + if (previous_date.isValid()) + Unload(previous_date); + GraphView->SaveSettings("Daily"); + QWidget::closeEvent(event); +} + + void Daily::doToggleSession(Session * sess) { Q_UNUSED(sess) diff --git a/sleepyhead/daily.h b/sleepyhead/daily.h index 7207a687..9679b0e3 100644 --- a/sleepyhead/daily.h +++ b/sleepyhead/daily.h @@ -79,6 +79,8 @@ public: */ explicit Daily(QWidget *parent, gGraphView *shared); ~Daily(); + void closeEvent(QCloseEvent *); + /*! \fn ReloadGraphs() \brief Reload all graph information from disk and updates the view. */ diff --git a/sleepyhead/mainwindow.cpp b/sleepyhead/mainwindow.cpp index 10a05b4a..a6bc331a 100644 --- a/sleepyhead/mainwindow.cpp +++ b/sleepyhead/mainwindow.cpp @@ -242,17 +242,20 @@ void MainWindow::closeEvent(QCloseEvent * event) { if (daily) { daily->close(); - delete daily; + daily->deleteLater(); +// delete daily; } if (overview) { overview->close(); - delete overview; + overview->deleteLater(); +// delete overview; } if (oximetry) { oximetry->close(); - delete oximetry; + oximetry->deleteLater(); +// delete oximetry; } // Shutdown and Save the current User profile diff --git a/sleepyhead/overview.cpp b/sleepyhead/overview.cpp index 2d9dd5f3..089f2e32 100644 --- a/sleepyhead/overview.cpp +++ b/sleepyhead/overview.cpp @@ -299,13 +299,19 @@ Overview::Overview(QWidget *parent, gGraphView *shared) : } Overview::~Overview() { - GraphView->SaveSettings("Overview");//no trans - disconnect(this, SLOT(dateStart_currentPageChanged(int, int))); - disconnect(this, SLOT(dateEnd_currentPageChanged(int, int))); delete ui; delete icon_on; delete icon_off; } + +void Overview::closeEvent(QCloseEvent *event) +{ + GraphView->SaveSettings("Overview");//no trans + disconnect(this, SLOT(dateStart_currentPageChanged(int, int))); + disconnect(this, SLOT(dateEnd_currentPageChanged(int, int))); + QWidget::closeEvent(event); +} + gGraph *Overview::createGraph(QString name, QString units, YTickerType yttype) { int default_height = PROFILE.appearance->graphHeight(); diff --git a/sleepyhead/overview.h b/sleepyhead/overview.h index 8ccbb33b..fe4a146a 100644 --- a/sleepyhead/overview.h +++ b/sleepyhead/overview.h @@ -39,6 +39,7 @@ class Overview : public QWidget public: explicit Overview(QWidget *parent, gGraphView *shared = nullptr); ~Overview(); + void closeEvent(QCloseEvent *); //! \brief Returns Overview gGraphView object containing it's graphs gGraphView *graphView() { return GraphView; } diff --git a/sleepyhead/oximetry.cpp b/sleepyhead/oximetry.cpp index 8dfd098f..d6feb002 100644 --- a/sleepyhead/oximetry.cpp +++ b/sleepyhead/oximetry.cpp @@ -1248,10 +1248,16 @@ Oximetry::Oximetry(QWidget *parent, gGraphView *shared) : } Oximetry::~Oximetry() +{ + delete ui; +} + +void Oximetry::closeEvent(QCloseEvent *event) { delete oximeter; GraphView->SaveSettings("Oximetry"); - delete ui; + + QWidget::closeEvent(event); } void Oximetry::on_RefreshPortsButton_clicked() diff --git a/sleepyhead/oximetry.h b/sleepyhead/oximetry.h index 0bfac21d..762611a6 100644 --- a/sleepyhead/oximetry.h +++ b/sleepyhead/oximetry.h @@ -306,6 +306,7 @@ class Oximetry : public QWidget public: explicit Oximetry(QWidget *parent, gGraphView *shared = nullptr); ~Oximetry(); + void closeEvent(QCloseEvent *); //! \brief Calls updateGL to redraw the graphs void RedrawGraphs();