Stop forcing 1 MiB gap when moving common partition boundary to the right (#227)
Start with 2 partitions next to each other, containing file systems that GParted can move and resize. EG: |[#1 ext2 ][#2 swap ] | Move the start of partition #2 to the right. Then attempt to move the end of partition #1 to the right to meet it. EG: |[#1 ext2 ][#2 swap ] | The Resize/Move dialog will allow the free space following to be set to 0 so partition #1 is again adjacent to partition #2, but after closing the dialog a forced 1 MiB gap is added, shrinking the composed size of partition #1 by that 1 MiB. If instead the first operation to shrink and move partition #2 is applied, then partition #1 can be successfully resize right up to partition #2 without a 1 MiB gap. Relevant call sequence: Win_GParted::activate_resize() Dialog_Partition_Resize_Move::Dialog_Partition_Resize_Move() Dialog_Base_Partition::Get_New_Partition() prepare_new_partition() snap_to_alignment() snap_to_mebibyte() prepare_new_partition() created a new partition object to correctly represent the resized/moved partition #1. However this code in snap_to_mebibyte() [1] determined that the new location for partition #1 overlapped with where partition #2 currently is on disk, not where partition #2 will be after the previous operation is applied, therefore it forced a 1 MiB decrease in partition #1's size creating the gap. This is because snap_to_mebibyte() is working with the on disk view of the partitions obtained from devices[current_device] passed into the Dialog_Partition_Resize_Move() constructor. Hence why applying the operations one at a time doesn't suffer from the forced 1 MiB gap. Fix this by creating a copy of the current device object, replacing the on disk partition layout with the composed partition layout as displayed in the UI. Then pass this into the Dialog_Partition_Resize_Move constructor. [1] Dialog_Base_Partition::snap_to_mebibyte() lines 418 to 438 https://gitlab.gnome.org/GNOME/gparted/-/blob/GPARTED_1_5_0/src/Dialog_Base_Partition.cc#L418 Closes #227 - Unable to allocate 1 MiB between partitions when moving to the right
This commit is contained in:
parent
ab76e5cf36
commit
2dd0100811
|
@ -2008,6 +2008,9 @@ void Win_GParted::activate_resize()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Device display_device = devices[current_device].get_copy_without_partitions();
|
||||||
|
display_device.partitions = display_partitions;
|
||||||
|
|
||||||
PartitionVector * display_partitions_ptr = &display_partitions;
|
PartitionVector * display_partitions_ptr = &display_partitions;
|
||||||
if ( selected_partition_ptr->type == TYPE_LOGICAL )
|
if ( selected_partition_ptr->type == TYPE_LOGICAL )
|
||||||
{
|
{
|
||||||
|
@ -2057,7 +2060,7 @@ void Win_GParted::activate_resize()
|
||||||
working_ptn = selected_partition_ptr->clone();
|
working_ptn = selected_partition_ptr->clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
Dialog_Partition_Resize_Move dialog(devices[current_device],
|
Dialog_Partition_Resize_Move dialog(display_device,
|
||||||
fs_cap,
|
fs_cap,
|
||||||
fs_limits,
|
fs_limits,
|
||||||
*working_ptn,
|
*working_ptn,
|
||||||
|
|
Loading…
Reference in New Issue