Thu, 23 Feb 2017 20:21:40 +0200
At long last, the g_win pointer has been removed. Down with global variables!
src/hierarchyelement.cpp | file | annotate | diff | comparison | revisions | |
src/main.cpp | file | annotate | diff | comparison | revisions | |
src/mainwindow.cpp | file | annotate | diff | comparison | revisions | |
src/mainwindow.h | file | annotate | diff | comparison | revisions |
--- a/src/hierarchyelement.cpp Thu Feb 23 20:18:39 2017 +0200 +++ b/src/hierarchyelement.cpp Thu Feb 23 20:21:40 2017 +0200 @@ -35,11 +35,10 @@ if (m_window == nullptr) { - // Drat! It doesn't seem to have the MainWindow as a parent! We'll need to force it to be in one. - // This shouldn't have any side effects but also shouldn't happen regardless. - m_window = g_win; - print("Hierarchy element instance %1 should have a MainWindow parent, but it is %2 (%3).\n", this, - parent, parent ? parent->metaObject()->className() : "nullptr"); + // The MainWindow relation should have been found. + QString error = format("Hierarchy element instance %1 should have a MainWindow parent, but it is %2 (%3).\n", + this, parent, parent ? parent->metaObject()->className() : "nullptr"); + throw std::runtime_error {error.toUtf8().constData()}; } m_documents = m_window->documents(); @@ -87,4 +86,4 @@ { QString caLicenseText = "!LICENSE Redistributable under CCAL version 2.0 : see CAreadme.txt"; return m_config->useCaLicense() ? caLicenseText : ""; -} \ No newline at end of file +}
--- a/src/main.cpp Thu Feb 23 20:18:39 2017 +0200 +++ b/src/main.cpp Thu Feb 23 20:21:40 2017 +0200 @@ -22,7 +22,6 @@ #include "documentmanager.h" #include "mainwindow.h" -MainWindow* g_win = nullptr; const Vertex Origin (0.0f, 0.0f, 0.0f); // =============================================================================
--- a/src/mainwindow.cpp Thu Feb 23 20:18:39 2017 +0200 +++ b/src/mainwindow.cpp Thu Feb 23 20:21:40 2017 +0200 @@ -63,7 +63,6 @@ m_currentDocument (nullptr), m_isSelectionLocked (false) { - g_win = this; m_messageLog = new MessageManager {this}; ui.setupUi (this); m_updatingTabs = false; @@ -170,7 +169,6 @@ MainWindow::~MainWindow() { - g_win = nullptr; delete m_guiUtilities; delete m_primitives; delete m_grid;
--- a/src/mainwindow.h Thu Feb 23 20:18:39 2017 +0200 +++ b/src/mainwindow.h Thu Feb 23 20:21:40 2017 +0200 @@ -177,7 +177,3 @@ void quickColorClicked(); void objectListDoubleClicked (QListWidgetItem* listitem); }; - -// Pointer to the instance of MainWindow. -// TODO: it's going out, slowly but surely. -extern MainWindow* g_win;