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
This commit is contained in:
Mike Fleetwood 2019-05-10 21:21:19 +01:00 committed by Curtis Gedak
parent 4101b0961b
commit 3222c8dd1a
8 changed files with 44 additions and 20 deletions

View File

@ -18,6 +18,8 @@
#ifndef GPARTED_DIALOG_BASE_PARTITION_H #ifndef GPARTED_DIALOG_BASE_PARTITION_H
#define GPARTED_DIALOG_BASE_PARTITION_H #define GPARTED_DIALOG_BASE_PARTITION_H
#include "Device.h"
#include "Frame_Resizer_Extended.h" #include "Frame_Resizer_Extended.h"
#include "FileSystem.h" #include "FileSystem.h"
#include "OptionComboBox.h" #include "OptionComboBox.h"
@ -37,7 +39,7 @@ class Dialog_Base_Partition : public Gtk::Dialog
{ {
public: public:
Dialog_Base_Partition( ) ; Dialog_Base_Partition(const Device& device);
~Dialog_Base_Partition( ) ; ~Dialog_Base_Partition( ) ;
void Set_Resizer( bool extended ) ; void Set_Resizer( bool extended ) ;
@ -90,6 +92,7 @@ protected:
bool fixed_start, GRIP ; bool fixed_start, GRIP ;
double before_value ; double before_value ;
const Device& m_device;
FS fs ; FS fs ;
FS_Limits fs_limits; // Working copy of file system min/max size limits FS_Limits fs_limits; // Working copy of file system min/max size limits

View File

@ -18,6 +18,8 @@
#ifndef GPARTED_DIALOG_PARTITION_COPY_H #ifndef GPARTED_DIALOG_PARTITION_COPY_H
#define GPARTED_DIALOG_PARTITION_COPY_H #define GPARTED_DIALOG_PARTITION_COPY_H
#include "Device.h"
#include "Dialog_Base_Partition.h" #include "Dialog_Base_Partition.h"
#include "FileSystem.h" #include "FileSystem.h"
#include "Partition.h" #include "Partition.h"
@ -28,9 +30,10 @@ namespace GParted
class Dialog_Partition_Copy : public Dialog_Base_Partition class Dialog_Partition_Copy : public Dialog_Base_Partition
{ {
public: public:
Dialog_Partition_Copy( const FS & fs, const FS_Limits & fs_limits, Dialog_Partition_Copy(const Device& device, const FS& fs,
const Partition & selected_partition, const FS_Limits& fs_limits,
const Partition & copied_partition ); const Partition& selected_partition,
const Partition& copied_partition);
~Dialog_Partition_Copy(); ~Dialog_Partition_Copy();
const Partition & Get_New_Partition(); const Partition & Get_New_Partition();

View File

@ -17,6 +17,8 @@
#ifndef GPARTED_DIALOG_PARTITION_RESIZE_MOVE_H #ifndef GPARTED_DIALOG_PARTITION_RESIZE_MOVE_H
#define GPARTED_DIALOG_PARTITION_RESIZE_MOVE_H #define GPARTED_DIALOG_PARTITION_RESIZE_MOVE_H
#include "Device.h"
#include "Dialog_Base_Partition.h" #include "Dialog_Base_Partition.h"
#include "FileSystem.h" #include "FileSystem.h"
#include "Partition.h" #include "Partition.h"
@ -28,9 +30,10 @@ namespace GParted
class Dialog_Partition_Resize_Move : public Dialog_Base_Partition class Dialog_Partition_Resize_Move : public Dialog_Base_Partition
{ {
public: public:
Dialog_Partition_Resize_Move( const FS & fs, const FS_Limits & fs_limits, Dialog_Partition_Resize_Move(const Device& device, const FS& fs,
const Partition & selected_partition, const FS_Limits& fs_limits,
const PartitionVector & partitions ); const Partition& selected_partition,
const PartitionVector& partitions);
~Dialog_Partition_Resize_Move(); ~Dialog_Partition_Resize_Move();
private: private:

View File

@ -15,6 +15,7 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>. * along with this program; if not, see <http://www.gnu.org/licenses/>.
*/ */
#include "Device.h"
#include "Dialog_Base_Partition.h" #include "Dialog_Base_Partition.h"
#include "Partition.h" #include "Partition.h"
#include "Utils.h" #include "Utils.h"
@ -24,8 +25,9 @@
namespace GParted namespace GParted
{ {
Dialog_Base_Partition::Dialog_Base_Partition() Dialog_Base_Partition::Dialog_Base_Partition(const Device& device)
: m_device(device)
{ {
frame_resizer_base = NULL; frame_resizer_base = NULL;
GRIP = false ; GRIP = false ;

View File

@ -15,6 +15,7 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>. * along with this program; if not, see <http://www.gnu.org/licenses/>.
*/ */
#include "Device.h"
#include "Dialog_Partition_Copy.h" #include "Dialog_Partition_Copy.h"
#include "FileSystem.h" #include "FileSystem.h"
#include "GParted_Core.h" #include "GParted_Core.h"
@ -24,9 +25,11 @@
namespace GParted namespace GParted
{ {
Dialog_Partition_Copy::Dialog_Partition_Copy( const FS & fs, const FS_Limits & fs_limits, Dialog_Partition_Copy::Dialog_Partition_Copy(const Device& device, const FS& fs,
const Partition & selected_partition, const FS_Limits& fs_limits,
const Partition & copied_partition ) const Partition& selected_partition,
const Partition& copied_partition)
: Dialog_Base_Partition(device)
{ {
this ->fs = fs ; this ->fs = fs ;
this->fs_limits = fs_limits; this->fs_limits = fs_limits;

View File

@ -15,6 +15,7 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>. * along with this program; if not, see <http://www.gnu.org/licenses/>.
*/ */
#include "Device.h"
#include "Dialog_Partition_New.h" #include "Dialog_Partition_New.h"
#include "FileSystem.h" #include "FileSystem.h"
#include "GParted_Core.h" #include "GParted_Core.h"
@ -32,6 +33,7 @@ Dialog_Partition_New::Dialog_Partition_New( const Device & device,
bool any_extended, bool any_extended,
unsigned short new_count, unsigned short new_count,
const std::vector<FS> & FILESYSTEMS ) const std::vector<FS> & FILESYSTEMS )
: Dialog_Base_Partition(device)
{ {
/*TO TRANSLATORS: dialogtitle */ /*TO TRANSLATORS: dialogtitle */
this ->set_title( _("Create new Partition") ) ; this ->set_title( _("Create new Partition") ) ;

View File

@ -15,6 +15,7 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>. * along with this program; if not, see <http://www.gnu.org/licenses/>.
*/ */
#include "Device.h"
#include "Dialog_Partition_Resize_Move.h" #include "Dialog_Partition_Resize_Move.h"
#include "FileSystem.h" #include "FileSystem.h"
#include "GParted_Core.h" #include "GParted_Core.h"
@ -25,9 +26,11 @@
namespace GParted namespace GParted
{ {
Dialog_Partition_Resize_Move::Dialog_Partition_Resize_Move( const FS & fs, const FS_Limits & fs_limits, Dialog_Partition_Resize_Move::Dialog_Partition_Resize_Move(const Device& device, const FS & fs,
const Partition & selected_partition, const FS_Limits & fs_limits,
const PartitionVector & partitions ) const Partition & selected_partition,
const PartitionVector & partitions)
: Dialog_Base_Partition(device)
{ {
this ->fs = fs ; this ->fs = fs ;
this->fs_limits = fs_limits; this->fs_limits = fs_limits;

View File

@ -2024,7 +2024,11 @@ void Win_GParted::activate_resize()
working_ptn = selected_partition_ptr->clone(); 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 ) ; dialog .set_transient_for( *this ) ;
delete working_ptn; delete working_ptn;
@ -2139,10 +2143,11 @@ void Win_GParted::activate_paste()
part_temp->clear_mountpoints(); part_temp->clear_mountpoints();
part_temp->name.clear(); part_temp->name.clear();
Dialog_Partition_Copy dialog( gparted_core.get_fs( copied_filesystem_ptn.filesystem ), Dialog_Partition_Copy dialog(devices[current_device],
fs_limits, gparted_core.get_fs(copied_filesystem_ptn.filesystem),
*selected_partition_ptr, fs_limits,
*part_temp ); *selected_partition_ptr,
*part_temp);
delete part_temp; delete part_temp;
part_temp = NULL; part_temp = NULL;
dialog .set_transient_for( *this ); dialog .set_transient_for( *this );