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
#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

View File

@ -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();

View File

@ -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:

View File

@ -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 ;

View File

@ -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;

View File

@ -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") ) ;

View File

@ -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;

View File

@ -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 );