From 7ac6588090cd491145fa83a65b7af645264bb2a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20G=C3=A2teau?= Date: Fri, 11 Jul 2014 17:08:56 +0200 Subject: [PATCH] Forget pending changes when the partition table is recreated --- src/modules/partition/PartitionCoreModule.cpp | 19 +++++++++++++++---- src/modules/partition/PartitionCoreModule.h | 2 ++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/modules/partition/PartitionCoreModule.cpp b/src/modules/partition/PartitionCoreModule.cpp index e2863e804..c1bb28c20 100644 --- a/src/modules/partition/PartitionCoreModule.cpp +++ b/src/modules/partition/PartitionCoreModule.cpp @@ -82,6 +82,14 @@ PartitionCoreModule::DeviceInfo::hasRootMountPoint() const return false; } +void +PartitionCoreModule::DeviceInfo::forgetChanges() +{ + jobs.clear(); + qDeleteAll( m_partitionInfoHash ); + m_partitionInfoHash.clear(); +} + //- PartitionCoreModule ------------------------------------ PartitionCoreModule::PartitionCoreModule( QObject* parent ) : QObject( parent ) @@ -128,13 +136,16 @@ PartitionCoreModule::partitionModelForDevice( Device* device ) const void PartitionCoreModule::createPartitionTable( Device* device ) { + DeviceInfo* info = infoForDevice( device ); + // Creating a partition table wipes all the disk, so there is no need to + // keep previous changes + info->forgetChanges(); + CreatePartitionTableJob* job = new CreatePartitionTableJob( device ); job->updatePreview(); - refreshPartitionModel( device ); + info->jobs << Calamares::job_ptr( job ); - // FIXME: Remove all jobs queued for this device, as well as all partition - // info - infoForDevice( device )->jobs << Calamares::job_ptr( job ); + refreshPartitionModel( device ); updateHasRootMountPoint(); } diff --git a/src/modules/partition/PartitionCoreModule.h b/src/modules/partition/PartitionCoreModule.h index 8ee079310..5c404868a 100644 --- a/src/modules/partition/PartitionCoreModule.h +++ b/src/modules/partition/PartitionCoreModule.h @@ -92,6 +92,8 @@ private: void removeInfoForPartition( Partition* partition ); bool hasRootMountPoint() const; + + void forgetChanges(); private: QHash< Partition*, PartitionInfo* > m_partitionInfoHash; };