Fix temporary path name of new partitions (#759488)

In the UI new partitions were being named "unallocated" instead of
"New Partition #1", etc.  Also deleting a new partition not yet created
deletes all new partitions from the operation list because it matches
by name only and they were all named "unallocated".  Broken by this
recent commit:

    762cd1094a
    Return class member from Dialog_Partition_New::Get_New_Partition() (#757671)

Prior to this commit in the create new partition dialog code did these
relevant steps:
    Dialog_Partition_New::Get_New_Partition()
        Partition part_temp;
        ...
        part_temp.Set(..., "New Partition #%1", ...);

Create local Partition object using default constructor which calls
Partition::Reset() and clears the paths vector.  It then calls Set()
which appends the new name making the vector:
    paths = ["New Partition #%1"]

After the above commit the code did these steps:
    Dialog_Partition_New::Dialog_Partition_New(..., selected_partition, ...)
        set_data(..., selected_partition, ...);
            new_partition = selected_partition;

    Dialog_Partition_New::Get_New_Partition(...)
        new_partition.Set(..., "New Partition #%1", ...);

New_partition is copied from the selected unallocated partition in which
the new partition will be created.  So new_partition is now named
"unallocated".  Then the Set() call appends the new name making the
vector:
    paths = ["unallocated", "New Partition #%1"]

As get_path() returns the first name in the paths vector the path name
changed from "New Partition #%1" to "unallocated" causing this bug.

Fix by resetting the new_partition object to clear all vestiges of it
being a copy of the selected unallocated partition, Reset() call, before
then calling Set().  This then appends the new name to an empty vector
making it contain just the required new name:
    paths = ["New Partition #%1"]

Bug 759488 - Pending create partitions are all getting named
             "unallocated"
This commit is contained in:
Mike Fleetwood 2015-12-15 12:50:09 +00:00 committed by Curtis Gedak
parent ae434579e1
commit c249b7286d
1 changed files with 10 additions and 4 deletions

View File

@ -209,14 +209,20 @@ const Partition & Dialog_Partition_New::Get_New_Partition( Byte_Value sector_siz
if ( (new_partition.sector_end - new_end) < (MEBIBYTE / sector_size) )
new_end = new_partition.sector_end;
new_partition.status = STAT_NEW;
new_partition.Set( new_partition.device_path, // NOTE: Glib::ustring object self assignment
// Copy a final few values needed from the original unallocated partition before
// resetting the Partition object and populating it as the new partition.
Glib::ustring device_path = new_partition.device_path;
bool whole_device = new_partition.whole_device;
bool inside_extended = new_partition.inside_extended;
new_partition.Reset();
new_partition.Set( device_path,
String::ucompose( _("New Partition #%1"), new_count ),
new_count, part_type, new_partition.whole_device,
new_count, part_type, whole_device,
FILESYSTEMS[optionmenu_filesystem.get_history()].filesystem,
new_start, new_end,
sector_size,
new_partition.inside_extended, false );
inside_extended, false );
new_partition.status = STAT_NEW;
// Retrieve partition name
new_partition.name = Utils::trim( partition_name_entry.get_text() );