Fixed bug in copy functionality (due to unset ORIG_START startsector

* include/Dialog_Base_Partition.h,
  src/Dialog_Base_Partition.cc,
  src/Dialog_Partition_Copy.cc,
  src/Dialog_Partition_Resize_Move.cc: Fixed bug in copy functionality (due to unset ORIG_START startsector wasn't set correctly). Also have ORIG*
  initialized in ctor of dialogbase to prevent such errors from ever happening again (this one only showed up with gcc-3.3.5) .
This commit is contained in:
Bart Hakvoort 2005-01-22 17:23:52 +00:00
parent 56c3a42c01
commit f25b28be07
5 changed files with 46 additions and 44 deletions

View File

@ -1,3 +1,11 @@
2005-01-22 Bart Hakvoort <hakvoort@cvs.gnome.org>
* include/Dialog_Base_Partition.h,
src/Dialog_Base_Partition.cc,
src/Dialog_Partition_Copy.cc,
src/Dialog_Partition_Resize_Move.cc: Fixed bug in copy functionality (due to unset ORIG_START startsector wasn't set correctly). Also have ORIG*
initialized in ctor of dialogbase to prevent such errors from ever happening again (this one only showed up with gcc-3.3.5) .
2005-01-19 Bart Hakvoort <hakvoort@cvs.gnome.org>
* src/GParted_Core.cc: removed sleep( 1 ). This isn't needed anymore now the layout is scanned before the re-readtest. (saves seconds at scantime :) )

View File

@ -83,7 +83,7 @@ protected:
short BUF ; //used in resize and copy ( safety reasons )
private:
void Check_Change() ;
void Check_Change( ) ;
Gtk::VBox vbox_resize_move;
Gtk::Label label_minmax ;

View File

@ -28,6 +28,7 @@ Dialog_Base_Partition::Dialog_Base_Partition( )
GRIP = false ;
this ->fixed_start = false ;
this ->set_resizable( false );
ORIG_BEFORE = ORIG_SIZE = ORIG_AFTER = -1 ;
//pack resizer hbox
this ->get_vbox( ) ->pack_start( hbox_resizer, Gtk::PACK_SHRINK );
@ -39,7 +40,7 @@ Dialog_Base_Partition::Dialog_Base_Partition( )
this ->get_vbox( ) ->pack_start( hbox_main, Gtk::PACK_SHRINK );
//put the vbox with resizer stuff (cool widget and spinbuttons) in the hbox_main
hbox_main .pack_start( vbox_resize_move, Gtk::PACK_EXPAND_PADDING);
hbox_main .pack_start( vbox_resize_move, Gtk::PACK_EXPAND_PADDING );
//fill table
table_resize .set_border_width( 5 ) ;
@ -50,28 +51,28 @@ Dialog_Base_Partition::Dialog_Base_Partition( )
vbox_resize_move .pack_start( hbox_table, Gtk::PACK_SHRINK );
//add spinbutton_before
table_resize.attach( * mk_label( (Glib::ustring) _( "Free Space Preceding (MB):") + " \t" ), 0, 1, 0, 1, Gtk::SHRINK);
table_resize.attach( * mk_label( (Glib::ustring) _( "Free Space Preceding (MB):") + " \t" ), 0, 1, 0, 1, Gtk::SHRINK );
spinbutton_before .set_numeric( true );
spinbutton_before .set_increments( 1, 100 );
table_resize.attach( spinbutton_before, 1, 2, 0, 1, Gtk::FILL);
table_resize.attach( spinbutton_before, 1, 2, 0, 1, Gtk::FILL );
//add spinbutton_size
table_resize.attach( * mk_label( _( "New Size (MB):" ) ), 0, 1, 1, 2 );
spinbutton_size .set_numeric( true );
spinbutton_size .set_increments( 1, 100 );
table_resize.attach( spinbutton_size, 1, 2, 1, 2, Gtk::FILL);
table_resize.attach( spinbutton_size, 1, 2, 1, 2, Gtk::FILL );
//add spinbutton_after
table_resize.attach( * mk_label( _( "Free Space Following (MB):") ), 0, 1, 2, 3 ) ;
spinbutton_after .set_numeric( true );
spinbutton_after .set_increments( 1, 100 );
table_resize.attach( spinbutton_after, 1, 2, 2, 3, Gtk::FILL);
table_resize.attach( spinbutton_after, 1, 2, 2, 3, Gtk::FILL );
if ( ! fixed_start )
before_value = spinbutton_before .get_value() ;
before_value = spinbutton_before .get_value( ) ;
//connect signalhandlers of the spinbuttons
if ( ! fixed_start )
@ -85,27 +86,25 @@ Dialog_Base_Partition::Dialog_Base_Partition( )
this ->get_vbox( ) ->pack_start( * mk_label( "" ), Gtk::PACK_SHRINK ); //filler :-P
this->add_button( Gtk::Stock::CANCEL,Gtk::RESPONSE_CANCEL );
this->add_button( Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL );
this ->show_all_children( ) ;
}
void Dialog_Base_Partition::Set_Resizer( bool extended )
{
if ( extended )
{
frame_resizer_base = new Frame_Resizer_Extended( ) ;
}
else
{
frame_resizer_base = new Frame_Resizer_Base( ) ;
frame_resizer_base ->signal_move .connect ( sigc::mem_fun( this, &Dialog_Base_Partition::on_signal_move) );
frame_resizer_base ->signal_move .connect( sigc::mem_fun( this, &Dialog_Base_Partition::on_signal_move ) );
}
frame_resizer_base ->set_border_width( 5 ) ;
frame_resizer_base ->set_shadow_type(Gtk::SHADOW_ETCHED_OUT);
frame_resizer_base ->set_shadow_type( Gtk::SHADOW_ETCHED_OUT );
//connect signals
frame_resizer_base ->signal_resize .connect ( sigc::mem_fun( this, &Dialog_Base_Partition::on_signal_resize) );
frame_resizer_base ->signal_resize .connect( sigc::mem_fun( this, &Dialog_Base_Partition::on_signal_resize ) );
hbox_resizer .pack_start( *frame_resizer_base, Gtk::PACK_EXPAND_PADDING );
@ -115,22 +114,22 @@ void Dialog_Base_Partition::Set_Resizer( bool extended )
Partition Dialog_Base_Partition::Get_New_Partition( )
{
if ( ORIG_BEFORE != spinbutton_before .get_value_as_int( ) )
selected_partition .sector_start = START + (Sector) spinbutton_before .get_value() * MEGABYTE ;
selected_partition .sector_start = START + spinbutton_before .get_value_as_int( ) * MEGABYTE ;
if ( ORIG_AFTER != spinbutton_after .get_value_as_int( ) )
selected_partition .sector_end = selected_partition .sector_start + (Sector) spinbutton_size .get_value( ) * MEGABYTE ;
selected_partition .sector_end = selected_partition .sector_start + spinbutton_size .get_value_as_int( ) * MEGABYTE ;
//due to loss of precision during calcs from Sector -> MB and back, it is possible the new partition thinks it's bigger then it can be. Here we solve this.
if ( selected_partition.sector_start < START )
selected_partition.sector_start = START ;
if ( selected_partition.sector_end > (START + total_length) )
selected_partition.sector_end = START + total_length ;
if ( selected_partition .sector_start < START )
selected_partition .sector_start = START ;
if ( selected_partition .sector_end > (START + total_length) )
selected_partition .sector_end = START + total_length ;
//grow a bit into small freespace ( < 1MB )
if ( (selected_partition.sector_start - START) < MEGABYTE )
selected_partition.sector_start = START ;
if ( ( START + total_length - selected_partition.sector_end ) < MEGABYTE )
selected_partition.sector_end = START + total_length ;
if ( (selected_partition .sector_start - START) < MEGABYTE )
selected_partition .sector_start = START ;
if ( ( START + total_length - selected_partition .sector_end ) < MEGABYTE )
selected_partition .sector_end = START + total_length ;
//set new value of unused..
if ( selected_partition .sectors_used != -1 )
@ -143,20 +142,18 @@ void Dialog_Base_Partition::Set_Confirm_Button( CONFIRMBUTTON button_type )
{
switch( button_type )
{
case NEW : this->add_button( Gtk::Stock::ADD, Gtk::RESPONSE_OK );
case NEW : this ->add_button( Gtk::Stock::ADD, Gtk::RESPONSE_OK );
break ;
case RESIZE_MOVE: str_temp = fixed_start ? _("Resize") : _("Resize/Move") ;
image_temp = manage( new Gtk::Image( Gtk::Stock::GOTO_LAST, Gtk::ICON_SIZE_BUTTON ) );
case RESIZE_MOVE: image_temp = manage( new Gtk::Image( Gtk::Stock::GOTO_LAST, Gtk::ICON_SIZE_BUTTON ) );
hbox_resize_move .pack_start( *image_temp, Gtk::PACK_EXPAND_PADDING ) ;
hbox_resize_move .pack_start( * mk_label( str_temp ), Gtk::PACK_EXPAND_PADDING ) ;
hbox_resize_move .pack_start( * mk_label( fixed_start ? _("Resize") : _("Resize/Move") ), Gtk::PACK_EXPAND_PADDING ) ;
button_resize_move .add( hbox_resize_move ) ;
this ->add_action_widget ( button_resize_move,Gtk::RESPONSE_OK ) ;
this ->add_action_widget ( button_resize_move, Gtk::RESPONSE_OK ) ;
button_resize_move .set_sensitive( false ) ;
break ;
case PASTE : this->add_button( Gtk::Stock::PASTE,Gtk::RESPONSE_OK );
case PASTE : this ->add_button( Gtk::Stock::PASTE, Gtk::RESPONSE_OK );
break ;
}
}
@ -172,18 +169,15 @@ void Dialog_Base_Partition::on_signal_move( int x_start, int x_end )
{
GRIP = true ;
if ( x_start == 0 )
spinbutton_before .set_value( 0 ) ;
else
spinbutton_before .set_value( x_start * MB_PER_PIXEL ) ;
spinbutton_before .set_value( x_start == 0 ? 0 : x_start * MB_PER_PIXEL ) ;
if ( x_end == 500 )
{
spinbutton_after .set_value(0 ) ;
spinbutton_before .set_value( TOTAL_MB - spinbutton_size .get_value() ) ;
spinbutton_after .set_value( 0 ) ;
spinbutton_before .set_value( TOTAL_MB - spinbutton_size .get_value( ) ) ;
}
else
spinbutton_after .set_value( TOTAL_MB - spinbutton_before .get_value() - spinbutton_size .get_value() ) ;
spinbutton_after .set_value( TOTAL_MB - spinbutton_before .get_value( ) - spinbutton_size .get_value( ) ) ;
Check_Change( ) ;
@ -265,9 +259,9 @@ void Dialog_Base_Partition::on_spinbutton_value_changed( SPINBUTTON spinbutton )
void Dialog_Base_Partition::Check_Change( )
{
if ( ORIG_BEFORE == spinbutton_before .get_value_as_int( ) &&
ORIG_SIZE == spinbutton_size .get_value_as_int( ) &&
ORIG_AFTER== spinbutton_after .get_value_as_int( )
if ( ORIG_BEFORE == spinbutton_before .get_value_as_int( ) &&
ORIG_SIZE == spinbutton_size .get_value_as_int( ) &&
ORIG_AFTER == spinbutton_after .get_value_as_int( )
)
button_resize_move .set_sensitive( false ) ;
else

View File

@ -72,7 +72,7 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons
spinbutton_after .set_value( TOTAL_MB - COPIED_LENGTH_MB ) ;
GRIP = false ;
frame_resizer_base ->set_size_limits( static_cast<int> (fs .MIN / MB_PER_PIXEL), static_cast<int> (fs .MAX / MB_PER_PIXEL) +1 ) ;
frame_resizer_base ->set_size_limits( Round(fs .MIN / MB_PER_PIXEL), Round(fs .MAX / MB_PER_PIXEL) +1 ) ;
//set contents of label_minmax
Set_MinMax_Text( fs .MIN, fs .MAX ) ;
@ -80,7 +80,7 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons
//set global selected_partition (see Dialog_Base_Partition::Get_New_Partition )
this ->selected_partition = copied_partition ;
this ->selected_partition .inside_extended = selected_partition .inside_extended ;
selected_partition .inside_extended ? this ->selected_partition .type = GParted::LOGICAL : this ->selected_partition .type = GParted::PRIMARY ;
this ->selected_partition .type = selected_partition .inside_extended ? GParted::LOGICAL : GParted::PRIMARY ;
}
Partition Dialog_Partition_Copy::Get_New_Partition( )
@ -89,7 +89,7 @@ Partition Dialog_Partition_Copy::Get_New_Partition( )
selected_partition = Dialog_Base_Partition::Get_New_Partition( ) ;
//set proper name and status for partition
selected_partition.status = GParted::STAT_COPY ;
selected_partition .status = GParted::STAT_COPY ;
return selected_partition ;
}

View File

@ -141,7 +141,7 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector <Partit
spinbutton_after .set_range( 0, TOTAL_MB - fs .MIN ) ;
spinbutton_after .set_value( Sector_To_MB( next ) ) ;
frame_resizer_base ->set_size_limits( static_cast<int> (fs .MIN / MB_PER_PIXEL), static_cast<int> (fs .MAX / MB_PER_PIXEL) +1 ) ;
frame_resizer_base ->set_size_limits( Round( fs .MIN / MB_PER_PIXEL ), Round( fs .MAX / MB_PER_PIXEL ) +1 ) ;
//set contents of label_minmax
Set_MinMax_Text( fs .MIN, fs .MAX ) ;