[gparted] Localise counting of primary partitions into max_amount_prim_reached()
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Localise counting of primary partitions into max_amount_prim_reached()
- Date: Tue, 22 Sep 2015 17:29:49 +0000 (UTC)
commit 3b5471516c569df865caf395f4da03b171817105
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Thu Sep 10 17:40:35 2015 +0100
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] 545b75d9574e053cadb9ddd5cf15fc28181da87c
Move vector of partition objects to a Win_GParted class member (#750168)
include/Win_GParted.h | 1 -
src/Win_GParted.cc | 20 +++++++++-----------
2 files changed, 9 insertions(+), 12 deletions(-)
---
diff --git a/include/Win_GParted.h b/include/Win_GParted.h
index ee1d668..ddeb6b3 100644
--- a/include/Win_GParted.h
+++ b/include/Win_GParted.h
@@ -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 ;
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index 5fe4ccd..d60de13 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -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 )
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]