diff --git a/src/calamares/CalamaresWindow.cpp b/src/calamares/CalamaresWindow.cpp index 271e22cb9..f8d2c15d6 100644 --- a/src/calamares/CalamaresWindow.cpp +++ b/src/calamares/CalamaresWindow.cpp @@ -142,7 +142,7 @@ CalamaresWindow::CalamaresWindow( QWidget* parent ) CalamaresUtils::unmarginLayout( sideLayout ); CalamaresUtils::unmarginLayout( mainLayout ); - Calamares::ViewManager* vm = new Calamares::ViewManager( this ); + Calamares::ViewManager* vm = Calamares::ViewManager::instance( this ); mainLayout->addWidget( vm->centralWidget() ); } diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index ad433d2fa..976377840 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -42,13 +42,20 @@ ViewManager::instance() return s_instance; } +ViewManager* +ViewManager::instance( QObject* parent ) +{ + Q_ASSERT( !s_instance ); + s_instance = new ViewManager( parent ); + return s_instance; +} + ViewManager::ViewManager( QObject* parent ) : QObject( parent ) , m_widget( new QWidget() ) , m_currentStep( 0 ) { Q_ASSERT( !s_instance ); - s_instance = this; QBoxLayout* mainLayout = new QVBoxLayout; m_widget->setLayout( mainLayout ); diff --git a/src/libcalamaresui/ViewManager.h b/src/libcalamaresui/ViewManager.h index 6e694a14a..f2f0ca57a 100644 --- a/src/libcalamaresui/ViewManager.h +++ b/src/libcalamaresui/ViewManager.h @@ -43,12 +43,10 @@ class UIDLLEXPORT ViewManager : public QObject public: /** * @brief instance access to the ViewManager singleton. - * @return + * @return pointer to the singleton instance. */ static ViewManager* instance(); - - explicit ViewManager( QObject* parent = nullptr ); - virtual ~ViewManager(); + static ViewManager* instance( QObject* parent ); /** * @brief centralWidget always returns the central widget in the Calamares main @@ -115,6 +113,9 @@ signals: void currentStepChanged(); private: + explicit ViewManager( QObject* parent = nullptr ); + virtual ~ViewManager(); + void insertViewStep( int before, ViewStep* step ); static ViewManager* s_instance;