[gparted] Fix visually re-applying copy new operation in create-copy-grow-first sequence (#755214)



commit 0e8f24b92b0a6ef497ed5db51a5d64a6acfdcccb
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Sun Sep 27 09:04:33 2015 +0100

    Fix visually re-applying copy new operation in create-copy-grow-first sequence (#755214)
    
    This is the equivalent case fixed in the earlier commit, but now using
    copy/paste to create the second new partition rather than plain new.
        Fix visually re-apply create operation in create-create-grow-first
        sequence (#755214)
    
    Start with an existing partition as a copy source.  Then this sequence
    of operations will cause the copy partition to disappear from the disk
    graphic:
    1) create new #1,
    2) copy existing / paste into unallocated leaving space preceding,
    3) resize new #1 larger.
    
    There are two different types of copy operation.  The first is copy into
    unallocated space creating a new partition which needs treating the same
    as create new operation.  The second is copy into existing partition
    which needs treating the same as the other operations which don't change
    the boundaries of the partition.  Fix apply_to_visual() accordingly.
    
    Bug 755214 - Refactor operation merging

 src/OperationCopy.cc |   35 +++++------------------------------
 1 files changed, 5 insertions(+), 30 deletions(-)
---
diff --git a/src/OperationCopy.cc b/src/OperationCopy.cc
index 528d4bf..bdd6d8d 100644
--- a/src/OperationCopy.cc
+++ b/src/OperationCopy.cc
@@ -38,37 +38,12 @@ OperationCopy::OperationCopy( const Device & device,
        
 void OperationCopy::apply_to_visual( std::vector<Partition> & partitions ) 
 {
-       index = index_extended = -1 ;
-       
-       if ( partition_original .inside_extended )
-       {
-               index_extended = find_index_extended( partitions ) ;
-               
-               if ( index_extended >= 0 )
-                       index = find_index_original( partitions[ index_extended ] .logicals ) ;
-
-               if ( index >= 0 )
-               {
-                       partitions[ index_extended ] .logicals[ index ] = partition_new ;       
-
-                       insert_unallocated( partitions[ index_extended ] .logicals,
-                                           partitions[ index_extended ] .sector_start,
-                                           partitions[ index_extended ] .sector_end,
-                                           device .sector_size,
-                                           true ) ;
-               }
-       }
+       if ( partition_original.type == TYPE_UNALLOCATED )
+               // Paste into unallocated space creating new partition
+               insert_new( partitions );
        else
-       {
-               index = find_index_original( partitions ) ;
-
-               if ( index >= 0 )
-               {
-                       partitions[ index ] = partition_new ;
-               
-                       insert_unallocated( partitions, 0, device .length -1, device .sector_size, false ) ;
-               }
-       }
+               // Paste into existing partition
+               substitute_new( partitions );
 }
 
 void OperationCopy::create_description() 


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