From 7235baf156220b389ebf6a48ca38bc2fbbdcab41 Mon Sep 17 00:00:00 2001 From: Bart Hakvoort Date: Sun, 28 Nov 2004 14:30:15 +0000 Subject: [PATCH] selecting 'extended partition' twice caused a segfault. i cannot believe i * src/Dialog_Partition_New.cc: selecting 'extended partition' twice caused a segfault. i cannot believe i didn't detect this bug earlier :| Fixed. also made it possible to create an unformatted partition. * src/GParted_Core.cc: backend support for creating partition without filesystem (unformatted). --- ChangeLog | 6 ++++++ src/Dialog_Partition_New.cc | 10 +++++----- src/GParted_Core.cc | 4 ++++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index eb470834..ff248393 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-11-28 Bart Hakvoort + + * src/Dialog_Partition_New.cc: selecting 'extended partition' twice caused a segfault. i cannot believe i didn't detect this bug earlier :| Fixed. + also made it possible to create an unformatted partition. + * src/GParted_Core.cc: backend support for creating partition without filesystem (unformatted). + 2004-11-28 Bart Hakvoort * src/Dialog_Disklabel.cc, diff --git a/src/Dialog_Partition_New.cc b/src/Dialog_Partition_New.cc index e142981a..46d22547 100644 --- a/src/Dialog_Partition_New.cc +++ b/src/Dialog_Partition_New.cc @@ -42,7 +42,8 @@ void Dialog_Partition_New::Set_Data( const Partition & partition, bool any_exten this ->new_count = new_count; this ->selected_partition = partition; this ->FILESYSTEMS = FILESYSTEMS ; - this ->FILESYSTEMS .erase( this ->FILESYSTEMS .end( ) ) ;//remove dummy "unknown" + this ->FILESYSTEMS .back( ) .filesystem = _("Unformatted") ; + this ->FILESYSTEMS .back( ) .create = true ; FS fs ; fs.filesystem = "extended" ; this ->FILESYSTEMS .push_back( fs ) ; @@ -167,13 +168,13 @@ void Dialog_Partition_New::optionmenu_changed( bool type ) //optionmenu_type if ( type ) { - if ( optionmenu_type .get_history( ) == GParted::EXTENDED ) + if ( optionmenu_type .get_history( ) == GParted::EXTENDED && menu_filesystem .items( ) .size( ) < FILESYSTEMS .size( ) ) { menu_filesystem .items( ) .push_back( Gtk::Menu_Helpers::MenuElem( "extended" ) ) ; optionmenu_filesystem .set_history( menu_filesystem .items( ) .size( ) -1 ) ; optionmenu_filesystem .set_sensitive( false ) ; } - else if ( menu_filesystem .items( ) .size( ) == FILESYSTEMS .size( ) ) + else if ( optionmenu_type .get_history( ) != GParted::EXTENDED && menu_filesystem .items( ) .size( ) == FILESYSTEMS .size( ) ) { menu_filesystem .items( ) .remove( menu_filesystem .items( ) .back( ) ) ; optionmenu_filesystem .set_sensitive( true ) ; @@ -185,8 +186,7 @@ void Dialog_Partition_New::optionmenu_changed( bool type ) if ( ! type ) { //needed vor upper limit check (see also Dialog_Base_Partition::on_signal_resize ) - //BART: i don't understand previous sentence, but i think this one's needed for correct color.. - selected_partition .filesystem = FILESYSTEMS[ optionmenu_filesystem .get_history() ] .filesystem ; + selected_partition .filesystem = FILESYSTEMS[ optionmenu_filesystem .get_history( ) ] .filesystem ; //set new spinbutton ranges long MIN, MAX; diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index 8e5e5551..14865a91 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -297,6 +297,10 @@ bool GParted_Core::Create( const Glib::ustring & device_path, Partition & new_pa { set_proper_filesystem( new_partition .filesystem ) ; + //most likely this means the user created an unformatted partition, however in theory, it could also screw some errorhandling. + if ( ! p_filesystem ) + return true ; + return p_filesystem ->Create( device_path, new_partition ) ; }