diff --git a/ChangeLog b/ChangeLog index ddc1eac6..ad1d75ef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-12-27 Bart Hakvoort + + * include/Device.h, + src/Device.cc, + src/GParted_Core.cc, + src/Win_GParted.cc: Removed the ugly Get_Highest_Logical_Busy() from Device and added a classvariable instead. This one is set in + GParted_Core and used wherever needed. I also removed Device::busy, and used the new variable to check if a device is busy. + 2004-12-27 Bart Hakvoort * Added cylsize to Device and made Operation contain a Device instead of only the path and lenght. diff --git a/include/Device.h b/include/Device.h index 6e96216b..a2b40da1 100644 --- a/include/Device.h +++ b/include/Device.h @@ -31,8 +31,7 @@ public: ~Device( ) ; void Reset( ) ; - int Get_Highest_Logical_Busy( ) ; - + std::vector device_partitions ; Sector length; long heads ; @@ -44,7 +43,7 @@ public: Glib::ustring realpath; Glib::ustring disktype; int max_prims ; - bool busy ; + int highest_busy ; bool readonly ; private: diff --git a/src/Device.cc b/src/Device.cc index b652d4ab..8775cacb 100644 --- a/src/Device.cc +++ b/src/Device.cc @@ -31,25 +31,8 @@ void Device::Reset( ) length = 0 ; heads = sectors = cylinders = cylsize = 0 ; model = path = realpath = disktype = "" ; - max_prims = 0 ; - busy = readonly = false ; -} - -int Device::Get_Highest_Logical_Busy( ) -{ - int highest_logic_busy = -1 ; - - for ( unsigned int t = 0 ; t < device_partitions .size( ) ; t++ ) - if ( device_partitions [ t ] .type == GParted::EXTENDED ) - { - for ( unsigned int i = 0 ; i < device_partitions[ t ] .logicals .size( ) ; i++ ) - if ( device_partitions[ t ] .logicals[ i ] .busy && device_partitions[ t ] .logicals[ i ] .partition_number > highest_logic_busy ) - highest_logic_busy = device_partitions[ t ] .logicals[ i ] .partition_number ; - - break ; - } - - return highest_logic_busy ; + max_prims = highest_busy = 0 ; + readonly = false ; } Device::~Device( ) diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index 1e386eef..ba129de4 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -107,7 +107,7 @@ void GParted_Core::get_devices( std::vector & devices ) set_device_partitions( temp_device ) ; - if ( temp_device .busy ) + if ( temp_device .highest_busy ) { temp_device .readonly = ! ped_disk_commit_to_os( disk ) ; sleep( 1 ) ;//this sucks, but it seems that after the commit test, the paths are removed and added again (which takes time..) @@ -184,9 +184,9 @@ void GParted_Core::set_device_partitions( Device & device ) partition_temp .flags = Get_Flags( c_partition ) ; - if ( partition_temp .busy ) - device .busy = true ; - + if ( partition_temp .busy && partition_temp .partition_number > device .highest_busy ) + device .highest_busy = partition_temp .partition_number ; + break ; case PED_PARTITION_EXTENDED: diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc index ae8e0327..1abc6829 100644 --- a/src/Win_GParted.cc +++ b/src/Win_GParted.cc @@ -940,7 +940,7 @@ void Win_GParted::activate_new() } } -void Win_GParted::activate_delete() +void Win_GParted::activate_delete( ) { //since logicals are *always* numbered from 5 to there can be a shift in numbers after deletion. //e.g. consider /dev/hda5 /dev/hda6 /dev/hda7. Now after removal of /dev/hda6, /dev/hda7 is renumbered to /dev/hda6 @@ -948,7 +948,7 @@ void Win_GParted::activate_delete() //it seems best to check for this and prohibit deletion with some explanation to the user. if ( selected_partition .type == GParted::LOGICAL && selected_partition .status != GParted::STAT_NEW && - selected_partition .partition_number < devices [ current_device ] .Get_Highest_Logical_Busy( ) ) + selected_partition .partition_number < devices [ current_device ] .highest_busy ) { str_temp = "" ; str_temp += _( "Unable to delete partition!") ; @@ -1156,7 +1156,7 @@ void Win_GParted::activate_apply( ) //find out if any of the involved devices is busy bool any_busy = false ; for ( unsigned int t = 0; t < devices .size( ) && ! any_busy; t++ ) - if ( devices[ t ] .busy ) + if ( devices[ t ] .highest_busy ) for (unsigned int i = 0; i < operations .size( ) && ! any_busy; i++ ) if ( operations[ i ] .device .path == devices[ t ] .path ) any_busy = true ;