[gparted] New partition dialog: first filesystem in list is always included



commit 1197a521741316868922b3e8b6db24059b481d63
Author: Rogier Goossens <goossens rogier gmail com>
Date:   Sat Feb 18 12:40:11 2012 +0100

    New partition dialog: first filesystem in list is always included
    
    Even if invalid, the first filesystem in list is always included.
    
    This is an off-by-one error, which was triggered when the first member
    of FILESYSTEMS was no longer a regular filesystem, as a result of
    commit ce9feeda0e9a04da04cec0a1b01512ed68c2495c:
    'Make FileSystem objects in GParted_Core accessible and usable by others'

 src/Dialog_Partition_New.cc |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/src/Dialog_Partition_New.cc b/src/Dialog_Partition_New.cc
index 4d3647d..6e75715 100644
--- a/src/Dialog_Partition_New.cc
+++ b/src/Dialog_Partition_New.cc
@@ -46,13 +46,15 @@ void Dialog_Partition_New::Set_Data( const Partition & partition,
 	this ->FILESYSTEMS = FILESYSTEMS ;
 
 	//remove all non-valid file systems
-	for ( unsigned int t = this ->FILESYSTEMS .size( ) ; t > 0 ; t-- )
+	std::vector< FS >::iterator f ;
+	for ( f = this->FILESYSTEMS .begin(); f != this->FILESYSTEMS .end(); f++ )
 	{
-		if ( this ->FILESYSTEMS[ t ] .filesystem == GParted::FS_UNKNOWN ||
-		     this ->FILESYSTEMS[ t ] .filesystem == GParted::FS_LVM2_PV ||
-		     this ->FILESYSTEMS[ t ] .filesystem == GParted::FS_LUKS
+		if ( f ->filesystem == GParted::FS_UNKNOWN
+		    || f ->filesystem == GParted::FS_LVM2_PV
+		    || f ->filesystem == GParted::FS_LUKS
 		   )
-			this ->FILESYSTEMS .erase( this->FILESYSTEMS .begin() + t ) ;
+			//Compensate for subsequent 'f++' ...
+			f = this ->FILESYSTEMS .erase( f ) - 1 ;
 	}
 
 	FS fs_tmp ;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]