From c86822c2f47973528b3441d633b2b9df98ed465a Mon Sep 17 00:00:00 2001 From: Boris Barbulovski Date: Wed, 12 Feb 2014 15:22:54 +0100 Subject: Replace mainWindow() with MainWindow::instance() C++ style of accessing single instance class object. Signed-off-by: Boris Barbulovski Signed-off-by: Dirk Hohndel --- qt-ui/mainwindow.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'qt-ui/mainwindow.cpp') diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 217c66dbb..8795b93df 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -36,12 +36,7 @@ #include "printdialog.h" #include "divelogimportdialog.h" -static MainWindow* instance = 0; - -MainWindow* mainWindow() -{ - return instance; -} +MainWindow *MainWindow::m_Instance = NULL; MainWindow::MainWindow() : QMainWindow(), actionNextDive(0), @@ -49,7 +44,7 @@ MainWindow::MainWindow() : QMainWindow(), helpView(0), state(VIEWALL) { - instance = this; + m_Instance = this; ui.setupUi(this); setWindowIcon(QIcon(":subsurface-icon")); connect(ui.ListWidget, SIGNAL(currentDiveChanged(int)), this, SLOT(current_dive_changed(int))); @@ -79,6 +74,16 @@ MainWindow::MainWindow() : QMainWindow(), #endif } +MainWindow::~MainWindow() +{ + m_Instance = NULL; +} + +MainWindow *MainWindow::instance() +{ + return m_Instance; +} + // this gets called after we download dives from a divecomputer void MainWindow::refreshDisplay(bool recreateDiveList) { -- cgit v1.2.3-70-g09d2