Fix numerical mismatch when graphically moving logical partition (#628554)

This commit is contained in:
Curtis Gedak 2010-09-07 16:56:38 -06:00
parent e172ebbb2e
commit 9d4ae28759
2 changed files with 18 additions and 15 deletions

View File

@ -241,8 +241,8 @@ void Dialog_Base_Partition::on_signal_move( int x_start, int x_end )
{
GRIP = true ;
spinbutton_before .set_value( x_start <= MIN_SPACE_BEFORE_MB * MB_PER_PIXEL ? MIN_SPACE_BEFORE_MB : x_start * MB_PER_PIXEL ) ;
spinbutton_before .set_value( x_start * MB_PER_PIXEL ) ;
if ( x_end == 500 )
{
spinbutton_after .set_value( 0 ) ;
@ -275,17 +275,8 @@ void Dialog_Base_Partition::on_signal_resize( int x_start, int x_end, Frame_Resi
spinbutton_after .set_value( TOTAL_MB - before_value - spinbutton_size .get_value() ) ;
}
else if ( arrow == Frame_Resizer_Base::ARROW_LEFT ) //don't touch freespace after, leave it as it is
{
if ( x_start <= MIN_SPACE_BEFORE_MB * MB_PER_PIXEL )
{
spinbutton_before .set_value( MIN_SPACE_BEFORE_MB );
spinbutton_size .set_value( TOTAL_MB - MIN_SPACE_BEFORE_MB - spinbutton_after.get_value() ) ;
}
else
spinbutton_before .set_value(
TOTAL_MB - spinbutton_size .get_value() - spinbutton_after .get_value() ) ;
}
spinbutton_before .set_value( TOTAL_MB - spinbutton_size .get_value() - spinbutton_after .get_value() ) ;
Check_Change() ;
GRIP = false ;

View File

@ -103,7 +103,13 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector<Partiti
if ( t +1 < partitions .size() && partitions[t +1] .type == GParted::TYPE_UNALLOCATED )
next = partitions[t +1] .get_sector_length() ;
MIN_SPACE_BEFORE_MB = Dialog_Base_Partition::MB_Needed_for_Boot_Record( selected_partition ) ;
//Only calculate MIN_SPACE_BEFORE_MB if we have a previous (unallocated) partition.
// Otherwise there will not be enough graphical space to reserve a full 1 MiB for MBR/EBR.
// Since this is an existing partition, if an MBR/EBR was needed then it already exists with enough space.
if ( previous <= 0 )
MIN_SPACE_BEFORE_MB = 0 ;
else
MIN_SPACE_BEFORE_MB = Dialog_Base_Partition::MB_Needed_for_Boot_Record( selected_partition ) ;
total_length = previous + selected_partition .get_sector_length() + next;
TOTAL_MB = Utils::round( Utils::sector_to_unit( total_length, selected_partition .sector_size, UNIT_MIB ) ) ;
@ -193,7 +199,13 @@ void Dialog_Partition_Resize_Move::Resize_Move_Extended( const std::vector<Parti
next = partitions[ t +1 ] .get_sector_length() ;
//now we have enough data to calculate some important values..
MIN_SPACE_BEFORE_MB = Dialog_Base_Partition::MB_Needed_for_Boot_Record( selected_partition ) ;
//Only calculate MIN_SPACE_BEFORE_MB if we have a previous (unallocated) partition.
// Otherwise there will not be enough graphical space to reserve a full 1 MiB for MBR/EBR.
// Since this is an existing partition, if an MBR/EBR was needed then it already exists with enough space.
if ( previous <= 0 )
MIN_SPACE_BEFORE_MB = 0 ;
else
MIN_SPACE_BEFORE_MB = Dialog_Base_Partition::MB_Needed_for_Boot_Record( selected_partition ) ;
total_length = previous + selected_partition .get_sector_length() + next;
TOTAL_MB = Utils::round( Utils::sector_to_unit( total_length, selected_partition .sector_size, UNIT_MIB ) ) ;
MB_PER_PIXEL = TOTAL_MB / 500.00 ;