Use current Device object for Create and Paste dialogs too (#227)
The Create New and Paste dialogs also create partitions and have to honour currently composed partitions while doing so. Therefore they must have a Device object containing the currently composed partition layout for passing into snap_to_alignment() and below. So copy the current Device object when refreshing the visual at the same time visual_partitions is generated and use in all 3 dialogs which compose new partitions. Note that Create New and Paste aren't subject to the same bug as Resize/ Move was because the code in snap_to_mebibyte() [1] checked the partition object being composed has status STAT_REAL. This is true for partition objects created by the Resize/Move dialog, but not true for the Create New and Paste dialogs which set status to STAT_NEW and STAT_COPY respectively instead. [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
2dd0100811
commit
e9f3977452
|
@ -213,6 +213,7 @@ private:
|
|||
// in Win_GParted::display_partitions[] vector).
|
||||
const Partition * copied_partition; // NULL or copy of source partition object.
|
||||
std::vector<Device> devices;
|
||||
Device m_display_device; // Copy of devices[current_device] with copy of display_partitions.
|
||||
std::vector<Operation *> operations;
|
||||
|
||||
//gui stuff
|
||||
|
|
|
@ -979,9 +979,12 @@ void Win_GParted::Refresh_Visual()
|
|||
// devices.clear()
|
||||
// etc.
|
||||
//
|
||||
// (2) Takes a copy of the partitions for the device currently being shown in the
|
||||
// GUI and visually applies pending operations.
|
||||
// (2) Takes a copy of the device and partitions for the device currently being
|
||||
// shown in the GUI and visually applies pending operations.
|
||||
//
|
||||
// Data owner: Device Win_GParted::m_display_device
|
||||
// Lifetime: Valid until the next call to Refresh_Visual().
|
||||
// Function: Refresh_Visual()
|
||||
// Data owner: PartitionVector Win_GParted::display_partitions
|
||||
// Lifetime: Valid until the next call to Refresh_Visual().
|
||||
// Function: Refresh_Visual()
|
||||
|
@ -1052,6 +1055,9 @@ void Win_GParted::Refresh_Visual()
|
|||
for ( unsigned int t = 0 ; t < operations .size(); t++ )
|
||||
if ( operations[ t ] ->device == devices[ current_device ] )
|
||||
operations[t]->apply_to_visual( display_partitions );
|
||||
|
||||
m_display_device = devices[current_device].get_copy_without_partitions();
|
||||
m_display_device.partitions = display_partitions;
|
||||
|
||||
hbox_operations .load_operations( operations ) ;
|
||||
|
||||
|
@ -2008,9 +2014,6 @@ void Win_GParted::activate_resize()
|
|||
return;
|
||||
}
|
||||
|
||||
Device display_device = devices[current_device].get_copy_without_partitions();
|
||||
display_device.partitions = display_partitions;
|
||||
|
||||
PartitionVector * display_partitions_ptr = &display_partitions;
|
||||
if ( selected_partition_ptr->type == TYPE_LOGICAL )
|
||||
{
|
||||
|
@ -2060,7 +2063,7 @@ void Win_GParted::activate_resize()
|
|||
working_ptn = selected_partition_ptr->clone();
|
||||
}
|
||||
|
||||
Dialog_Partition_Resize_Move dialog(display_device,
|
||||
Dialog_Partition_Resize_Move dialog(m_display_device,
|
||||
fs_cap,
|
||||
fs_limits,
|
||||
*working_ptn,
|
||||
|
@ -2253,7 +2256,7 @@ void Win_GParted::activate_paste()
|
|||
part_temp->clear_mountpoints();
|
||||
part_temp->name.clear();
|
||||
|
||||
Dialog_Partition_Copy dialog(devices[current_device],
|
||||
Dialog_Partition_Copy dialog(m_display_device,
|
||||
gparted_core.get_fs(copied_filesystem_ptn.fstype),
|
||||
fs_limits,
|
||||
*selected_partition_ptr,
|
||||
|
@ -2412,11 +2415,11 @@ void Win_GParted::activate_new()
|
|||
// decide whether to allow the creation of the only extended partition
|
||||
// type or not.
|
||||
bool any_extended = ( find_extended_partition( display_partitions ) >= 0 );
|
||||
Dialog_Partition_New dialog( devices[current_device],
|
||||
*selected_partition_ptr,
|
||||
any_extended,
|
||||
new_count,
|
||||
gparted_core.get_filesystems() );
|
||||
Dialog_Partition_New dialog(m_display_device,
|
||||
*selected_partition_ptr,
|
||||
any_extended,
|
||||
new_count,
|
||||
gparted_core.get_filesystems());
|
||||
dialog .set_transient_for( *this );
|
||||
|
||||
if ( dialog .run() == Gtk::RESPONSE_OK )
|
||||
|
|
Loading…
Reference in New Issue