From 1197a521741316868922b3e8b6db24059b481d63 Mon Sep 17 00:00:00 2001 From: Rogier Goossens Date: Sat, 18 Feb 2012 12:40:11 +0100 Subject: [PATCH] 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 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Dialog_Partition_New.cc b/src/Dialog_Partition_New.cc index 4d3647d2..6e757156 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 ;