From 067eeb018da01581c53b8f15556fc71118a5f19a Mon Sep 17 00:00:00 2001 From: Volker Lanz Date: Thu, 15 Apr 2010 17:34:34 +0000 Subject: [PATCH] Do not merge resize/new/delete ops if an extended partition is involved: Too many things can go wrong, all of them leading to crashes. BUG:232092 svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1115229 --- TODO | 4 ---- src/core/operationstack.cpp | 15 +++++++++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/TODO b/TODO index 92d2d69..283a5a8 100644 --- a/TODO +++ b/TODO @@ -15,10 +15,6 @@ Bugs to fix for 1.1: * copy&paste seems broken wrt alignment when copying from cylinder aligned to sector aligned drives (maybe even more than that) -* resizing a newly created extended that has children (leading to a merge of - operations) crashes in NewOperation::description(). this is intermittent - and probably fixed in r1107315. - * make sure the default file system can indeed be created =============================================================================== diff --git a/src/core/operationstack.cpp b/src/core/operationstack.cpp index 300b3c0..5494dc4 100644 --- a/src/core/operationstack.cpp +++ b/src/core/operationstack.cpp @@ -67,11 +67,13 @@ OperationStack::~OperationStack()
  1. An existing operation created a Partition that is now being deleted: In this case, just remove - the corresponding NewOperation from the OperationStack.
  2. + the corresponding NewOperation from the OperationStack.
    This does not work for + extended partitions.(#232092)
  3. An existing Operation created a Partition that is now being moved or resized. In this case, remove the original NewOperation and create a new NewOperation with updated start and end - sectors. This new NewOperation is appended to the OperationStack.
  4. + sectors. This new NewOperation is appended to the OperationStack.
    This does not work for + extended partitions.(#232092)
  5. An existing NewOperation created a Partition that is now being copied. We're not copying but instead creating another new Partition in its place.
  6. @@ -99,7 +101,7 @@ bool OperationStack::mergeNewOperation(Operation*& currentOp, Operation*& pushed CreateFileSystemOperation* pushedCreateFileSystemOp = dynamic_cast(pushedOp); // -- 1 -- - if (pushedDeleteOp && &newOp->newPartition() == &pushedDeleteOp->deletedPartition()) + if (pushedDeleteOp && &newOp->newPartition() == &pushedDeleteOp->deletedPartition() && !pushedDeleteOp->deletedPartition().roles().has(PartitionRole::Extended)) { Log() << i18nc("@info/plain", "Deleting a partition just created: Undoing the operation to create the partition."); @@ -113,8 +115,13 @@ bool OperationStack::mergeNewOperation(Operation*& currentOp, Operation*& pushed } // -- 2 -- - if (pushedResizeOp && &newOp->newPartition() == &pushedResizeOp->partition()) + if (pushedResizeOp && &newOp->newPartition() == &pushedResizeOp->partition() && !pushedResizeOp->partition().roles().has(PartitionRole::Extended)) { + // NOTE: In theory it would be possible to merge resizing an extended as long as it has no children. + // But that still doesn't save us: If we're not merging a resize on an extended that has children, + // a resizeop is added to the stack. Next, the user deletes the child. Then he resizes the + // extended again (a second resize): The ResizeOp still has the pointer to the original extended that + // will now be deleted. Log() << i18nc("@info/plain", "Resizing a partition just created: Updating start and end in existing operation."); Partition* newPartition = new Partition(newOp->newPartition());