[gparted] Fix temporary path name of new partitions (#759488)



commit c249b7286d552cffcfc661831715260e3196a354
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Tue Dec 15 12:50:09 2015 +0000

    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:
    
        762cd1094aece03986226a39d1f6b4fecfd73ee9
        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"

 src/Dialog_Partition_New.cc |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/src/Dialog_Partition_New.cc b/src/Dialog_Partition_New.cc
index 570e4ae..ac58032 100644
--- a/src/Dialog_Partition_New.cc
+++ b/src/Dialog_Partition_New.cc
@@ -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() );


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]