Clang: make ViewManager instance a proper singleton.

This commit is contained in:
Adriaan de Groot 2017-06-27 06:46:59 -04:00
parent 6a3aa01564
commit 09b25ab3e9
3 changed files with 14 additions and 6 deletions

View File

@ -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() );
}

View File

@ -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 );

View File

@ -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;