Localise counting of primary partitions into max_amount_prim_reached()
Now that display_partitions is a Win_GParted member variable and
therefore available throughout the class, since commit [1], calculation
of primary_count can be localised in max_amount_prim_reached() where it
is used.
Implements a FIXME and removes primary_count as a member variable.
[1] 545b75d957
Move vector of partition objects to a Win_GParted class member (#750168)
This commit is contained in:
parent
99e908f79b
commit
3b5471516c
|
@ -256,7 +256,6 @@ private:
|
|||
|
||||
//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 primary_count ;//primary_count checks for max. of 4 pimary partitions
|
||||
unsigned short new_count;//new_count keeps track of the new created partitions
|
||||
FS fs ;
|
||||
bool OPERATIONSLIST_OPEN ;
|
||||
|
|
|
@ -929,11 +929,9 @@ void Win_GParted::Refresh_Visual()
|
|||
if ( ! operations .size() )
|
||||
allow_undo_clear_apply( false ) ;
|
||||
|
||||
// Count primary partitions for check in max_amount_prim_reached(), check for an
|
||||
// extended partition, refresh copy partition source as necessary and select the
|
||||
// largest unallocated partition if there is one.
|
||||
// Check for an extended partition, refresh copy partition source as necessary and
|
||||
// select the largest unallocated partition if there is one.
|
||||
index_extended = -1 ;
|
||||
primary_count = 0;
|
||||
|
||||
selected_partition_ptr = NULL;
|
||||
Sector largest_unalloc_size = -1 ;
|
||||
|
@ -946,13 +944,8 @@ void Win_GParted::Refresh_Visual()
|
|||
|
||||
switch ( display_partitions[t].type )
|
||||
{
|
||||
case TYPE_PRIMARY:
|
||||
primary_count++;
|
||||
break;
|
||||
|
||||
case TYPE_EXTENDED:
|
||||
index_extended = t ;
|
||||
primary_count++;
|
||||
|
||||
for ( unsigned int u = 0 ; u < display_partitions[t].logicals.size() ; u ++ )
|
||||
{
|
||||
|
@ -1693,8 +1686,13 @@ void Win_GParted::on_partition_popup_menu( unsigned int button, unsigned int tim
|
|||
|
||||
bool Win_GParted::max_amount_prim_reached()
|
||||
{
|
||||
//FIXME: this is the only place where primary_count is used... instead of counting the primaries on each
|
||||
//refresh, we could just count them here.
|
||||
int primary_count = 0;
|
||||
for ( unsigned int i = 0 ; i < display_partitions.size() ; i ++ )
|
||||
{
|
||||
if ( display_partitions[i].type == TYPE_PRIMARY || display_partitions[i].type == TYPE_EXTENDED )
|
||||
primary_count ++;
|
||||
}
|
||||
|
||||
//Display error if user tries to create more primary partitions than the partition table can hold.
|
||||
if ( ! selected_partition_ptr->inside_extended && primary_count >= devices[current_device].max_prims )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue