[gparted] Pass the current device down to Dialog_Base_Partition class (#48)



commit 3222c8dd1a6fab117a75b5350c8f1bc796427383
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Fri May 10 21:21:19 2019 +0100

    Pass the current device down to Dialog_Base_Partition class (#48)
    
    The current device has to be passed to the dialog constructors and then
    on to the Dialog_Base_Constructor.  Note that the Dialog_Partition_New
    constructor is already passed the current device, however it still needs
    to pass it on to Dialog_Base_Constructor.
    
    This is ready so that snap_to_*() methods can access the current device
    when they are called from within these dialogs.
    
    * Pass Parameter to Base Class Constructor while creating Derived class
      Object
      
https://stackoverflow.com/questions/16585856/pass-parameter-to-base-class-constructor-while-creating-derived-class-object
    
    Closes #48 - Error when moving locked LUKS-encrypted partition

 include/Dialog_Base_Partition.h        |  5 ++++-
 include/Dialog_Partition_Copy.h        |  9 ++++++---
 include/Dialog_Partition_Resize_Move.h |  9 ++++++---
 src/Dialog_Base_Partition.cc           |  6 ++++--
 src/Dialog_Partition_Copy.cc           |  9 ++++++---
 src/Dialog_Partition_New.cc            |  2 ++
 src/Dialog_Partition_Resize_Move.cc    |  9 ++++++---
 src/Win_GParted.cc                     | 15 ++++++++++-----
 8 files changed, 44 insertions(+), 20 deletions(-)
---
diff --git a/include/Dialog_Base_Partition.h b/include/Dialog_Base_Partition.h
index ec9051eb..25a6a5cd 100644
--- a/include/Dialog_Base_Partition.h
+++ b/include/Dialog_Base_Partition.h
@@ -18,6 +18,8 @@
 #ifndef GPARTED_DIALOG_BASE_PARTITION_H
 #define GPARTED_DIALOG_BASE_PARTITION_H
 
+
+#include "Device.h"
 #include "Frame_Resizer_Extended.h"
 #include "FileSystem.h"
 #include "OptionComboBox.h"
@@ -37,7 +39,7 @@ class Dialog_Base_Partition : public Gtk::Dialog
 {
 public:
        
-       Dialog_Base_Partition( ) ;
+       Dialog_Base_Partition(const Device& device);
        ~Dialog_Base_Partition( ) ;
 
        void Set_Resizer( bool extended ) ;
@@ -90,6 +92,7 @@ protected:
 
        bool fixed_start, GRIP ;
        double before_value ;
+       const Device& m_device;
        FS fs ;
        FS_Limits fs_limits;  // Working copy of file system min/max size limits
 
diff --git a/include/Dialog_Partition_Copy.h b/include/Dialog_Partition_Copy.h
index bdc9c084..5e92270f 100644
--- a/include/Dialog_Partition_Copy.h
+++ b/include/Dialog_Partition_Copy.h
@@ -18,6 +18,8 @@
 #ifndef GPARTED_DIALOG_PARTITION_COPY_H
 #define GPARTED_DIALOG_PARTITION_COPY_H
 
+
+#include "Device.h"
 #include "Dialog_Base_Partition.h"
 #include "FileSystem.h"
 #include "Partition.h"
@@ -28,9 +30,10 @@ namespace GParted
 class Dialog_Partition_Copy : public Dialog_Base_Partition
 {
 public:
-       Dialog_Partition_Copy( const FS & fs, const FS_Limits & fs_limits,
-                              const Partition & selected_partition,
-                              const Partition & copied_partition );
+       Dialog_Partition_Copy(const Device& device, const FS& fs,
+                             const FS_Limits& fs_limits,
+                             const Partition& selected_partition,
+                             const Partition& copied_partition);
        ~Dialog_Partition_Copy();
 
        const Partition & Get_New_Partition();
diff --git a/include/Dialog_Partition_Resize_Move.h b/include/Dialog_Partition_Resize_Move.h
index 0f7dfe57..0284ac35 100644
--- a/include/Dialog_Partition_Resize_Move.h
+++ b/include/Dialog_Partition_Resize_Move.h
@@ -17,6 +17,8 @@
 #ifndef GPARTED_DIALOG_PARTITION_RESIZE_MOVE_H
 #define GPARTED_DIALOG_PARTITION_RESIZE_MOVE_H
 
+
+#include "Device.h"
 #include "Dialog_Base_Partition.h"
 #include "FileSystem.h"
 #include "Partition.h"
@@ -28,9 +30,10 @@ namespace GParted
 class Dialog_Partition_Resize_Move : public Dialog_Base_Partition
 {
 public:
-       Dialog_Partition_Resize_Move( const FS & fs, const FS_Limits & fs_limits,
-                                     const Partition & selected_partition,
-                                     const PartitionVector & partitions );
+       Dialog_Partition_Resize_Move(const Device& device, const FS& fs,
+                                    const FS_Limits& fs_limits,
+                                    const Partition& selected_partition,
+                                    const PartitionVector& partitions);
        ~Dialog_Partition_Resize_Move();
 
 private:
diff --git a/src/Dialog_Base_Partition.cc b/src/Dialog_Base_Partition.cc
index c9efec17..d3a50f52 100644
--- a/src/Dialog_Base_Partition.cc
+++ b/src/Dialog_Base_Partition.cc
@@ -15,6 +15,7 @@
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "Device.h"
 #include "Dialog_Base_Partition.h"
 #include "Partition.h"
 #include "Utils.h"
@@ -24,8 +25,9 @@
 
 namespace GParted
 {
-       
-Dialog_Base_Partition::Dialog_Base_Partition()
+
+Dialog_Base_Partition::Dialog_Base_Partition(const Device& device)
+ : m_device(device)
 {
        frame_resizer_base = NULL;
        GRIP = false ;
diff --git a/src/Dialog_Partition_Copy.cc b/src/Dialog_Partition_Copy.cc
index b81fc03f..98b42671 100644
--- a/src/Dialog_Partition_Copy.cc
+++ b/src/Dialog_Partition_Copy.cc
@@ -15,6 +15,7 @@
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "Device.h"
 #include "Dialog_Partition_Copy.h"
 #include "FileSystem.h"
 #include "GParted_Core.h"
@@ -24,9 +25,11 @@
 namespace GParted
 {
 
-Dialog_Partition_Copy::Dialog_Partition_Copy( const FS & fs, const FS_Limits & fs_limits,
-                                              const Partition & selected_partition,
-                                              const Partition & copied_partition )
+Dialog_Partition_Copy::Dialog_Partition_Copy(const Device& device, const FS& fs,
+                                             const FS_Limits& fs_limits,
+                                             const Partition& selected_partition,
+                                             const Partition& copied_partition)
+ : Dialog_Base_Partition(device)
 {
        this ->fs = fs ;
        this->fs_limits = fs_limits;
diff --git a/src/Dialog_Partition_New.cc b/src/Dialog_Partition_New.cc
index 2852ef06..92b8aa98 100644
--- a/src/Dialog_Partition_New.cc
+++ b/src/Dialog_Partition_New.cc
@@ -15,6 +15,7 @@
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "Device.h"
 #include "Dialog_Partition_New.h"
 #include "FileSystem.h"
 #include "GParted_Core.h"
@@ -32,6 +33,7 @@ Dialog_Partition_New::Dialog_Partition_New( const Device & device,
                                             bool any_extended,
                                             unsigned short new_count,
                                             const std::vector<FS> & FILESYSTEMS )
+ : Dialog_Base_Partition(device)
 {
        /*TO TRANSLATORS: dialogtitle */
        this ->set_title( _("Create new Partition") ) ;
diff --git a/src/Dialog_Partition_Resize_Move.cc b/src/Dialog_Partition_Resize_Move.cc
index 16e67cc7..44878623 100644
--- a/src/Dialog_Partition_Resize_Move.cc
+++ b/src/Dialog_Partition_Resize_Move.cc
@@ -15,6 +15,7 @@
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "Device.h"
 #include "Dialog_Partition_Resize_Move.h"
 #include "FileSystem.h"
 #include "GParted_Core.h"
@@ -25,9 +26,11 @@
 namespace GParted
 {
 
-Dialog_Partition_Resize_Move::Dialog_Partition_Resize_Move( const FS & fs, const FS_Limits & fs_limits,
-                                                            const Partition & selected_partition,
-                                                            const PartitionVector & partitions )
+Dialog_Partition_Resize_Move::Dialog_Partition_Resize_Move(const Device& device, const FS & fs,
+                                                           const FS_Limits & fs_limits,
+                                                           const Partition & selected_partition,
+                                                           const PartitionVector & partitions)
+ : Dialog_Base_Partition(device)
 {
        this ->fs = fs ;
        this->fs_limits = fs_limits;
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index 7e2d7138..2fdb2a7b 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -2024,7 +2024,11 @@ void Win_GParted::activate_resize()
                working_ptn = selected_partition_ptr->clone();
        }
 
-       Dialog_Partition_Resize_Move dialog( fs_cap, fs_limits, *working_ptn, *display_partitions_ptr );
+       Dialog_Partition_Resize_Move dialog(devices[current_device],
+                                           fs_cap,
+                                           fs_limits,
+                                           *working_ptn,
+                                           *display_partitions_ptr);
        dialog .set_transient_for( *this ) ;    
 
        delete working_ptn;
@@ -2139,10 +2143,11 @@ void Win_GParted::activate_paste()
                        part_temp->clear_mountpoints();
                        part_temp->name.clear();
 
-                       Dialog_Partition_Copy dialog( gparted_core.get_fs( copied_filesystem_ptn.filesystem ),
-                                                     fs_limits,
-                                                     *selected_partition_ptr,
-                                                     *part_temp );
+                       Dialog_Partition_Copy dialog(devices[current_device],
+                                                    gparted_core.get_fs(copied_filesystem_ptn.filesystem),
+                                                    fs_limits,
+                                                    *selected_partition_ptr,
+                                                    *part_temp);
                        delete part_temp;
                        part_temp = NULL;
                        dialog .set_transient_for( *this );


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