From 4282e4c31f95c6581478bea993bea73e232b62e2 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 2 Apr 2019 05:32:32 -0400 Subject: [PATCH] [partition] Instantiate the manual-partitioning page on-demand - When the manual partitioning page exists, it reacts to changes in a bunch of models; these models can be changed repeatedly from the choice page. - the manual partitioning page really only needs to deal with the relevant selections at the moment it is instantiated. --- .../partition/gui/PartitionViewStep.cpp | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/modules/partition/gui/PartitionViewStep.cpp b/src/modules/partition/gui/PartitionViewStep.cpp index 509edea13..371a039cb 100644 --- a/src/modules/partition/gui/PartitionViewStep.cpp +++ b/src/modules/partition/gui/PartitionViewStep.cpp @@ -90,15 +90,16 @@ void PartitionViewStep::continueLoading() { Q_ASSERT( !m_choicePage ); - Q_ASSERT( !m_manualPartitionPage ); - - m_manualPartitionPage = new PartitionPage( m_core ); m_choicePage = new ChoicePage( m_swapChoices ); - m_choicePage->init( m_core ); - m_widget->addWidget( m_choicePage ); - m_widget->addWidget( m_manualPartitionPage ); + + // Instantiate the manual partitioning page as needed. + // + Q_ASSERT( !m_manualPartitionPage ); + // m_manualPartitionPage = new PartitionPage( m_core ); + // m_widget->addWidget( m_manualPartitionPage ); + m_widget->removeWidget( m_waitingWidget ); m_waitingWidget->deleteLater(); m_waitingWidget = nullptr; @@ -287,6 +288,12 @@ PartitionViewStep::next() { if ( m_choicePage->currentChoice() == ChoicePage::Manual ) { + if ( !m_manualPartitionPage ) + { + m_manualPartitionPage = new PartitionPage( m_core ); + m_widget->addWidget( m_manualPartitionPage ); + } + m_widget->setCurrentWidget( m_manualPartitionPage ); m_manualPartitionPage->selectDeviceByIndex( m_choicePage->lastSelectedDeviceIndex() ); if ( m_core->isDirty() ) @@ -304,6 +311,12 @@ PartitionViewStep::back() { m_widget->setCurrentWidget( m_choicePage ); m_choicePage->setLastSelectedDeviceIndex( m_manualPartitionPage->selectedDeviceIndex() ); + + if ( m_manualPartitionPage ) + { + m_manualPartitionPage->deleteLater(); + m_manualPartitionPage = nullptr; + } } }