summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/mainwindow.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2019-09-27 16:26:54 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-09-27 16:26:58 -0700
commit9ae7040a91c3e3e0606d7abe085ef6da47efd6d2 (patch)
treede120b115df95fb96d945581aca41cd8c760263c /desktop-widgets/mainwindow.cpp
parent400b218f769320221567b7b66f39c33126a7d2e1 (diff)
downloadsubsurface-9ae7040a91c3e3e0606d7abe085ef6da47efd6d2.tar.gz
Revert the singleton PR
It turns out that this isn't working the way it was intended to. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'desktop-widgets/mainwindow.cpp')
-rw-r--r--desktop-widgets/mainwindow.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp
index ef55b3d06..bed142ecc 100644
--- a/desktop-widgets/mainwindow.cpp
+++ b/desktop-widgets/mainwindow.cpp
@@ -109,6 +109,8 @@ extern "C" int updateProgress(const char *text)
return progressDialogCanceled;
}
+MainWindow *MainWindow::m_Instance = nullptr;
+
extern "C" void showErrorFromC(char *buf)
{
QString error(buf);
@@ -126,6 +128,8 @@ MainWindow::MainWindow() : QMainWindow(),
survey(nullptr),
findMovedImagesDialog(nullptr)
{
+ Q_ASSERT_X(m_Instance == NULL, "MainWindow", "MainWindow recreated!");
+ m_Instance = this;
ui.setupUi(this);
read_hashes();
Command::init();
@@ -353,6 +357,7 @@ MainWindow::MainWindow() : QMainWindow(),
MainWindow::~MainWindow()
{
write_hashes();
+ m_Instance = nullptr;
}
void MainWindow::setupSocialNetworkMenu()
@@ -393,6 +398,11 @@ void MainWindow::setDefaultState()
ui.bottomLeft->currentWidget()->setEnabled(false);
}
+MainWindow *MainWindow::instance()
+{
+ return m_Instance;
+}
+
// This gets called after one or more dives were added, edited or downloaded for a dive computer
void MainWindow::refreshDisplay(bool doRecreateDiveList)
{