From fa5ed1fb90d1dd23e9a23b6719a0d567ef8d85f0 Mon Sep 17 00:00:00 2001 From: Mike Fleetwood Date: Sat, 20 Aug 2016 13:20:41 +0100 Subject: [PATCH] Select unallocated whole disk devices again (#788308) After the change from whole_device flag to TYPE_UNPARTITIONED, unallocated whole disk devices are no longer automatically selected because the partition type is no longer TYPE_UNALLOCATED. Fix by checking for file system type FS_UNALLOCATED when identifying the largest unallocated space. Bug 788308 - Remove whole_device partition flag --- src/Win_GParted.cc | 59 ++++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 34 deletions(-) diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc index 8e8e047c..305c2af1 100644 --- a/src/Win_GParted.cc +++ b/src/Win_GParted.cc @@ -941,46 +941,37 @@ void Win_GParted::Refresh_Visual() copied_partition = display_partitions[t].clone(); } - switch ( display_partitions[t].type ) + if ( display_partitions[t].filesystem == FS_UNALLOCATED ) { - case TYPE_EXTENDED: - for ( unsigned int u = 0 ; u < display_partitions[t].logicals.size() ; u ++ ) + current_size = display_partitions[t].get_sector_length(); + if ( current_size > largest_unalloc_size ) + { + largest_unalloc_size = current_size; + selected_partition_ptr = & display_partitions[t]; + } + } + + if ( display_partitions[t].type == TYPE_EXTENDED ) + { + for ( unsigned int u = 0 ; u < display_partitions[t].logicals.size() ; u ++ ) + { + if ( copied_partition != NULL && + display_partitions[t].logicals[u].get_path() == copied_partition->get_path() ) { - if ( copied_partition != NULL && - display_partitions[t].logicals[u].get_path() == copied_partition->get_path() ) - { - delete copied_partition; - copied_partition = display_partitions[t].logicals[u].clone(); - } + delete copied_partition; + copied_partition = display_partitions[t].logicals[u].clone(); + } - switch ( display_partitions[t].logicals[u].type ) + if ( display_partitions[t].logicals[u].filesystem == FS_UNALLOCATED ) + { + current_size = display_partitions[t].logicals[u].get_sector_length(); + if ( current_size > largest_unalloc_size ) { - case TYPE_UNALLOCATED: - current_size = display_partitions[t].logicals[u].get_sector_length(); - if ( current_size > largest_unalloc_size ) - { - largest_unalloc_size = current_size ; - selected_partition_ptr = & display_partitions[t].logicals[u]; - } - break; - - default: - break; + largest_unalloc_size = current_size; + selected_partition_ptr = & display_partitions[t].logicals[u]; } } - break; - - case TYPE_UNALLOCATED: - current_size = display_partitions[t].get_sector_length(); - if ( current_size > largest_unalloc_size ) - { - largest_unalloc_size = current_size ; - selected_partition_ptr = & display_partitions[t]; - } - break; - - default : - break; + } } }