From f60def5ecc1ceb35a24dca0705a36fe3fc01a349 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 14 Mar 2022 11:27:00 +0100 Subject: [PATCH] [partition] Don't reinitialize partition layout Existing code reinitialized the layout, losing whatever layout was set in the config. Refactor so that you can access the partition-layout API, and change the default FS through that -- which is the point of the code block here in `doAutopartition()`, to look up the currently- selected default FS. Inspired by Santosh's work in #1903, #1759. --- src/modules/partition/PartitionViewStep.cpp | 6 +++--- src/modules/partition/core/PartitionActions.cpp | 2 +- src/modules/partition/core/PartitionCoreModule.cpp | 6 ------ src/modules/partition/core/PartitionCoreModule.h | 6 +++--- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/modules/partition/PartitionViewStep.cpp b/src/modules/partition/PartitionViewStep.cpp index f3d4fc8ac..d9c9dbf0c 100644 --- a/src/modules/partition/PartitionViewStep.cpp +++ b/src/modules/partition/PartitionViewStep.cpp @@ -52,8 +52,8 @@ PartitionViewStep::PartitionViewStep( QObject* parent ) m_waitingWidget = new WaitingWidget( QString() ); m_widget->addWidget( m_waitingWidget ); - CALAMARES_RETRANSLATE( if ( m_waitingWidget ) - { m_waitingWidget->setText( tr( "Gathering system information..." ) ); } ); + CALAMARES_RETRANSLATE( + if ( m_waitingWidget ) { m_waitingWidget->setText( tr( "Gathering system information..." ) ); } ); m_core = new PartitionCoreModule( this ); // Unusable before init is complete! // We're not done loading, but we need the configuration map first. @@ -691,7 +691,7 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap ) QFuture< void > future = QtConcurrent::run( this, &PartitionViewStep::initPartitionCoreModule ); m_future->setFuture( future ); - m_core->initLayout( m_config->defaultFsType(), configurationMap.value( "partitionLayout" ).toList() ); + m_core->partitionLayout().init( m_config->defaultFsType(), configurationMap.value( "partitionLayout" ).toList() ); } diff --git a/src/modules/partition/core/PartitionActions.cpp b/src/modules/partition/core/PartitionActions.cpp index a56446a39..0ce9ff4ed 100644 --- a/src/modules/partition/core/PartitionActions.cpp +++ b/src/modules/partition/core/PartitionActions.cpp @@ -112,7 +112,7 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO // will log an error and set the type to Unknown if there's something wrong. FileSystem::Type type = FileSystem::Unknown; PartUtils::canonicalFilesystemName( o.defaultFsType, &type ); - core->initLayout( type == FileSystem::Unknown ? FileSystem::Ext4 : type ); + core->partitionLayout().setDefaultFsType( type == FileSystem::Unknown ? FileSystem::Ext4 : type ); core->createPartitionTable( dev, partType ); diff --git a/src/modules/partition/core/PartitionCoreModule.cpp b/src/modules/partition/core/PartitionCoreModule.cpp index 79adf7686..660e557a9 100644 --- a/src/modules/partition/core/PartitionCoreModule.cpp +++ b/src/modules/partition/core/PartitionCoreModule.cpp @@ -941,12 +941,6 @@ PartitionCoreModule::setBootLoaderInstallPath( const QString& path ) m_bootLoaderInstallPath = path; } -void -PartitionCoreModule::initLayout( FileSystem::Type defaultFsType, const QVariantList& config ) -{ - m_partLayout.init( defaultFsType, config ); -} - void PartitionCoreModule::layoutApply( Device* dev, qint64 firstSector, diff --git a/src/modules/partition/core/PartitionCoreModule.h b/src/modules/partition/core/PartitionCoreModule.h index eae16f0be..1ed46fdad 100644 --- a/src/modules/partition/core/PartitionCoreModule.h +++ b/src/modules/partition/core/PartitionCoreModule.h @@ -160,11 +160,11 @@ public: /// @brief Set the path where the bootloader will be installed void setBootLoaderInstallPath( const QString& path ); - /** @brief Initialize the default layout that will be applied + /** @brief Get the partition layout that will be applied. * - * See PartitionLayout::init() + * Layouts are applied only for erase and replace operations. */ - void initLayout( FileSystem::Type defaultFsType, const QVariantList& config = QVariantList() ); + PartitionLayout& partitionLayout() { return m_partLayout; } void layoutApply( Device* dev, qint64 firstSector, qint64 lastSector, QString luksPassphrase ); void layoutApply( Device* dev,