[gparted] Switch to using struct FS_Limits inside Dialog_Partition_Copy (#787204)



commit fc436595fd315b62280224e939745ef3aa749e20
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Fri Jan 12 10:04:37 2018 +0000

    Switch to using struct FS_Limits inside Dialog_Partition_Copy (#787204)
    
    Adds working copy fs_limits member into common Dialog_Base_Partition
    class.  Changes the internal code in Dialog_Partition_Copy class to use
    fs_limits instead of fs.MIN and fs.MAX.  The limits are still passed
    into the constructor via object of struct FS and it's members .MIN and
    .MAX but immediately used to assign to the fs_limits member.
    
    Bug 787204 - Minimum and maximum size of the UDF partition/disk

 include/Dialog_Base_Partition.h |    2 ++
 src/Dialog_Partition_Copy.cc    |   35 ++++++++++++++++++-----------------
 2 files changed, 20 insertions(+), 17 deletions(-)
---
diff --git a/include/Dialog_Base_Partition.h b/include/Dialog_Base_Partition.h
index f8fc819..3612400 100644
--- a/include/Dialog_Base_Partition.h
+++ b/include/Dialog_Base_Partition.h
@@ -20,6 +20,7 @@
 
 #include "Frame_Resizer_Extended.h"
 #include "Partition.h"
+#include "Utils.h"
 
 #include <gtkmm/dialog.h>
 #include <gtkmm/stock.h>
@@ -92,6 +93,7 @@ protected:
        bool fixed_start, GRIP ;
        double before_value ;
        FS fs ;
+       FS_Limits fs_limits;  // Working copy of file system min/max size limits
 
 private:
        Dialog_Base_Partition( const Dialog_Base_Partition & src );              // Not implemented copy 
constructor
diff --git a/src/Dialog_Partition_Copy.cc b/src/Dialog_Partition_Copy.cc
index 97eb01c..ee59961 100644
--- a/src/Dialog_Partition_Copy.cc
+++ b/src/Dialog_Partition_Copy.cc
@@ -27,6 +27,7 @@ Dialog_Partition_Copy::Dialog_Partition_Copy( const FS & fs, const Partition & s
                                               const Partition & copied_partition )
 {
        this ->fs = fs ;
+       fs_limits = FS_Limits( fs.MIN, fs.MAX );
 
        Set_Resizer( false ) ;  
        Set_Confirm_Button( PASTE ) ;
@@ -74,40 +75,40 @@ void Dialog_Partition_Copy::set_data( const Partition & selected_partition, cons
        //  system is implemented and resizing it is currently allowed.
        if ( fs .grow && ! GParted_Core::filesystem_resize_disallowed( copied_partition ) )
        {
-               if ( ! fs .MAX || fs .MAX > ((TOTAL_MB - MIN_SPACE_BEFORE_MB) * MEBIBYTE) )
-                       fs .MAX = ((TOTAL_MB - MIN_SPACE_BEFORE_MB) * MEBIBYTE) ;
+               if ( ! fs_limits.max_size || fs_limits.max_size > ((TOTAL_MB - MIN_SPACE_BEFORE_MB) * 
MEBIBYTE) )
+                       fs_limits.max_size = (TOTAL_MB - MIN_SPACE_BEFORE_MB) * MEBIBYTE;
        }
        else
-               fs .MAX = copied_partition .get_byte_length() ;
+       {
+               fs_limits.max_size = copied_partition.get_byte_length();
+       }
 
        if ( fs .filesystem == GParted::FS_XFS ) //bit hackisch, but most effective, since it's a unique 
situation
-               fs.MIN = std::max( fs.MIN, min_resize * copied_partition.sector_size );
+               fs_limits.min_size = std::max( fs_limits.min_size, min_resize * copied_partition.sector_size 
);
        else
-               fs .MIN = COPIED_LENGTH_MB * MEBIBYTE ;
-       
+               fs_limits.min_size = COPIED_LENGTH_MB * MEBIBYTE;
+
        GRIP = true ;
        //set values of spinbutton_before
-       spinbutton_before .set_range( MIN_SPACE_BEFORE_MB, TOTAL_MB - ceil( fs .MIN / double(MEBIBYTE) ) ) ;
+       spinbutton_before.set_range( MIN_SPACE_BEFORE_MB, TOTAL_MB - ceil( fs_limits.min_size / 
double(MEBIBYTE) ) );
        spinbutton_before .set_value( MIN_SPACE_BEFORE_MB ) ;
 
        //set values of spinbutton_size
-       spinbutton_size .set_range( ceil( fs .MIN / double(MEBIBYTE) )
-                                 , ceil( fs .MAX / double(MEBIBYTE) )
-                                 ) ;
+       spinbutton_size.set_range( ceil( fs_limits.min_size / double(MEBIBYTE) ),
+                                  ceil( fs_limits.max_size / double(MEBIBYTE) ) );
        spinbutton_size .set_value( COPIED_LENGTH_MB ) ;
        
        //set values of spinbutton_after
-       spinbutton_after .set_range( 0, TOTAL_MB - MIN_SPACE_BEFORE_MB - ceil( fs .MIN / double(MEBIBYTE) ) ) 
;
+       spinbutton_after.set_range( 0, TOTAL_MB - MIN_SPACE_BEFORE_MB - ceil( fs_limits.min_size / 
double(MEBIBYTE) ) );
        spinbutton_after .set_value( TOTAL_MB - MIN_SPACE_BEFORE_MB - COPIED_LENGTH_MB ) ; 
        GRIP = false ;
        
-       frame_resizer_base ->set_size_limits( Utils::round( fs .MIN / (MB_PER_PIXEL * MEBIBYTE) ),
-                                             Utils::round( fs .MAX / (MB_PER_PIXEL * MEBIBYTE) ) ) ;
-       
+       frame_resizer_base->set_size_limits( Utils::round( fs_limits.min_size / (MB_PER_PIXEL * MEBIBYTE) ),
+                                            Utils::round( fs_limits.max_size / (MB_PER_PIXEL * MEBIBYTE) ) );
+
        //set contents of label_minmax
-       Set_MinMax_Text( ceil( fs .MIN / double(MEBIBYTE) )
-                      , ceil( fs .MAX / double(MEBIBYTE) )
-                      ) ;
+       Set_MinMax_Text( ceil( fs_limits.min_size / double(MEBIBYTE) ),
+                        ceil( fs_limits.max_size / double(MEBIBYTE) ) );
 
        // Set member variable used in Dialog_Base_Partition::prepare_new_partition()
        new_partition = copied_partition.clone();


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