Localise checking for an extended partition into activate_new()

As previous commit, display_partitions is now a Win_GParted member
variable so checking for the existence of an extended partition can be
localised where it is used.

Remove index_extended member variable and localise the same checking in
activate_new().
This commit is contained in:
Mike Fleetwood 2015-09-10 18:24:49 +01:00 committed by Curtis Gedak
parent 3b5471516c
commit 26dc3dffa7
2 changed files with 15 additions and 8 deletions

View File

@ -255,7 +255,6 @@ private:
TOOLBAR_APPLY ;
//usefull variables which are used by many different functions...
int index_extended ; //position of the extended partition (-1 means there isn't one)
unsigned short new_count;//new_count keeps track of the new created partitions
FS fs ;
bool OPERATIONSLIST_OPEN ;

View File

@ -929,10 +929,8 @@ void Win_GParted::Refresh_Visual()
if ( ! operations .size() )
allow_undo_clear_apply( false ) ;
// Check for an extended partition, refresh copy partition source as necessary and
// select the largest unallocated partition if there is one.
index_extended = -1 ;
// Refresh copy partition source as necessary and select the largest unallocated
// partition if there is one.
selected_partition_ptr = NULL;
Sector largest_unalloc_size = -1 ;
Sector current_size ;
@ -945,8 +943,6 @@ void Win_GParted::Refresh_Visual()
switch ( display_partitions[t].type )
{
case TYPE_EXTENDED:
index_extended = t ;
for ( unsigned int u = 0 ; u < display_partitions[t].logicals.size() ; u ++ )
{
if ( display_partitions[t].logicals[u].get_path() == copied_partition.get_path() )
@ -1953,9 +1949,21 @@ void Win_GParted::activate_new()
}
else if ( ! max_amount_prim_reached() )
{
// Check if an extended partition already exist; so that the dialog can
// decide whether to allow the creation of the only extended partition
// type or not.
bool any_extended = false;
for ( unsigned int i = 0 ; i < display_partitions.size() ; i ++ )
{
if ( display_partitions[i].type == TYPE_EXTENDED )
{
any_extended = true;
break;
}
}
Dialog_Partition_New dialog( devices[current_device],
*selected_partition_ptr,
index_extended > -1,
any_extended,
new_count,
gparted_core.get_filesystems() );
dialog .set_transient_for( *this );