From fdf0f208f08de8d39c7f24ca7b406006bb5c686a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sat, 11 Dec 2021 23:26:12 +0100 Subject: [PATCH] [partition] Use lvalue-overload of execute() convenience - These jobs may take a long time, and report progress; we need the operation around to be able to connect the signals and slots --- .../partition/jobs/ResizePartitionJob.cpp | 20 +++++++------------ .../partition/jobs/SetPartitionFlagsJob.cpp | 15 ++++---------- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/src/modules/partition/jobs/ResizePartitionJob.cpp b/src/modules/partition/jobs/ResizePartitionJob.cpp index 87b87c1c0..fe1ceca4c 100644 --- a/src/modules/partition/jobs/ResizePartitionJob.cpp +++ b/src/modules/partition/jobs/ResizePartitionJob.cpp @@ -11,9 +11,10 @@ #include "ResizePartitionJob.h" +#include "core/KPMHelpers.h" + #include "utils/Units.h" -// KPMcore #include #include #include @@ -66,23 +67,16 @@ ResizePartitionJob::prettyStatusMessage() const Calamares::JobResult ResizePartitionJob::exec() { - Report report( nullptr ); // Restore partition sectors that were modified for preview m_partition->setFirstSector( m_oldFirstSector ); m_partition->setLastSector( m_oldLastSector ); + ResizeOperation op( *m_device, *m_partition, m_newFirstSector, m_newLastSector ); - op.setStatus( Operation::StatusRunning ); connect( &op, &Operation::progress, this, &ResizePartitionJob::iprogress ); - - QString errorMessage = tr( "The installer failed to resize partition %1 on disk '%2'." ) - .arg( m_partition->partitionPath() ) - .arg( m_device->name() ); - if ( op.execute( report ) ) - { - return Calamares::JobResult::ok(); - } - - return Calamares::JobResult::error( errorMessage, report.toText() ); + return KPMHelpers::execute( op, + tr( "The installer failed to resize partition %1 on disk '%2'." ) + .arg( m_partition->partitionPath() ) + .arg( m_device->name() ) ); } void diff --git a/src/modules/partition/jobs/SetPartitionFlagsJob.cpp b/src/modules/partition/jobs/SetPartitionFlagsJob.cpp index de77d86f8..507773288 100644 --- a/src/modules/partition/jobs/SetPartitionFlagsJob.cpp +++ b/src/modules/partition/jobs/SetPartitionFlagsJob.cpp @@ -13,6 +13,8 @@ #include "SetPartitionFlagsJob.h" +#include "core/KPMHelpers.h" + #include "partition/FileSystem.h" #include "utils/Logger.h" #include "utils/Units.h" @@ -148,17 +150,8 @@ SetPartFlagsJob::exec() cDebug() << "Setting flags on" << m_device->deviceNode() << "partition" << partition()->deviceNode() << Logger::DebugList( flagsList ); - Report report( nullptr ); SetPartFlagsOperation op( *m_device, *partition(), m_flags ); - op.setStatus( Operation::StatusRunning ); connect( &op, &Operation::progress, this, &SetPartFlagsJob::iprogress ); - - QString errorMessage - = tr( "The installer failed to set flags on partition %1." ).arg( m_partition->partitionPath() ); - if ( op.execute( report ) ) - { - return Calamares::JobResult::ok(); - } - - return Calamares::JobResult::error( errorMessage, report.toText() ); + return KPMHelpers::execute( + op, tr( "The installer failed to set flags on partition %1." ).arg( m_partition->partitionPath() ) ); }