diff --git a/src/ops/deactivatevolumegroupoperation.cpp b/src/ops/deactivatevolumegroupoperation.cpp index d135cff..a002e84 100644 --- a/src/ops/deactivatevolumegroupoperation.cpp +++ b/src/ops/deactivatevolumegroupoperation.cpp @@ -47,16 +47,13 @@ QString DeactivateVolumeGroupOperation::description() const void DeactivateVolumeGroupOperation::preview() { + m_PartitionTable = device().partitionTable(); device().setPartitionTable(new PartitionTable(PartitionTable::vmd, 0, device().totalLogical() - 1)); } void DeactivateVolumeGroupOperation::undo() { - PartitionTable* tmp = device().partitionTable(); - if (tmp != partitionTable()) { - device().setPartitionTable(partitionTable()); - delete tmp; - } + device().setPartitionTable(m_PartitionTable); } /** loop through given device's partitions to check if any is mounted. diff --git a/src/ops/deactivatevolumegroupoperation.h b/src/ops/deactivatevolumegroupoperation.h index 11a27c7..8f7acdb 100644 --- a/src/ops/deactivatevolumegroupoperation.h +++ b/src/ops/deactivatevolumegroupoperation.h @@ -73,10 +73,6 @@ protected: return m_Device; } - PartitionTable* partitionTable() { - return m_PartitionTable; - } - private: DeactivateVolumeGroupJob* m_DeactivateVolumeGroupJob; DeactivateLogicalVolumeJob* m_DeactivateLogicalVolumeJob; diff --git a/src/ops/removevolumegroupoperation.cpp b/src/ops/removevolumegroupoperation.cpp index f4cc861..c680f47 100644 --- a/src/ops/removevolumegroupoperation.cpp +++ b/src/ops/removevolumegroupoperation.cpp @@ -18,6 +18,7 @@ #include "ops/removevolumegroupoperation.h" #include "jobs/removevolumegroupjob.h" +#include "core/partitiontable.h" #include "core/volumemanagerdevice.h" #include @@ -41,8 +42,11 @@ QString RemoveVolumeGroupOperation::description() const void RemoveVolumeGroupOperation::preview() { + m_PartitionTable = device().partitionTable(); + device().setPartitionTable(new PartitionTable(PartitionTable::vmd, 0, device().totalLogical() - 1)); } void RemoveVolumeGroupOperation::undo() { + device().setPartitionTable(m_PartitionTable); } diff --git a/src/ops/removevolumegroupoperation.h b/src/ops/removevolumegroupoperation.h index 998c947..23cac18 100644 --- a/src/ops/removevolumegroupoperation.h +++ b/src/ops/removevolumegroupoperation.h @@ -25,6 +25,7 @@ #include +class PartitionTable; class RemoveVolumeGroupJob; class VolumeManagerDevice; class OperationStack; @@ -67,6 +68,7 @@ protected: private: RemoveVolumeGroupJob* m_RemoveVolumeGroupJob; VolumeManagerDevice& m_Device; + PartitionTable* m_PartitionTable; }; #endif