[gparted] Fix detection of empty mount point column for encrypted file systems (#775475)



commit 9e932ec7d0c2e6e56f1d0dd3495158fb492289b8
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Thu Dec 1 13:27:37 2016 +0000

    Fix detection of empty mount point column for encrypted file systems (#775475)
    
    create_row() populates the values for each row to be displayed in the UI
    from the relevant Partition object.  However load_partitions(5 params)
    independently decided if the Name, Mount Point and Label columns were
    empty and should be displayed.
    
    Getting the mount point value is more complex for encrypted file systems
    because it has to call get_mountpoints() on the inner encrypted
    Partition object.  load_partitions(5 params) didn't account for this.
    
    Fix by making create_row() both copy the values into each row and at the
    same time check if they are empty to decide if they should be displayed
    or not.
    
    Bug 775475 - Mount Point column displayed for encrypted file systems
                 even when empty

 include/TreeView_Detail.h |    6 +++++-
 src/TreeView_Detail.cc    |   30 ++++++++++++++++--------------
 2 files changed, 21 insertions(+), 15 deletions(-)
---
diff --git a/include/TreeView_Detail.h b/include/TreeView_Detail.h
index 2fa7ff7..592876f 100644
--- a/include/TreeView_Detail.h
+++ b/include/TreeView_Detail.h
@@ -53,7 +53,11 @@ private:
                              const Gtk::TreeRow & parent_row = Gtk::TreeRow() );
        bool set_selected( Gtk::TreeModel::Children rows,
                           const Partition * partition_ptr, bool inside_extended = false );
-       void create_row( const Gtk::TreeRow & treerow, const Partition & partition );
+       void create_row( const Gtk::TreeRow & treerow,
+                        const Partition & partition,
+                        bool & show_names,
+                        bool & show_mountpoints,
+                        bool & show_labels );
 
        //(overridden) signals
        bool on_button_press_event( GdkEventButton * event );
diff --git a/src/TreeView_Detail.cc b/src/TreeView_Detail.cc
index a68f37b..563dc85 100644
--- a/src/TreeView_Detail.cc
+++ b/src/TreeView_Detail.cc
@@ -117,19 +117,10 @@ void TreeView_Detail::load_partitions( const PartitionVector & partitions,
        for ( unsigned int i = 0 ; i < partitions .size() ; i++ ) 
        {       
                row = parent_row ? *( treestore_detail ->append( parent_row .children() ) ) : *( 
treestore_detail ->append() ) ;
-               create_row( row, partitions[ i ] );
-               
+               create_row( row, partitions[i], names, mountpoints, labels );
+
                if ( partitions[ i ] .type == GParted::TYPE_EXTENDED )
                        load_partitions( partitions[i].logicals, mountpoints, labels, names, row );
-
-               if ( partitions[ i ] .get_mountpoints() .size() )
-                       mountpoints = true ;
-                                       
-               if ( ! partitions[ i ].get_filesystem_label().empty() )
-                       labels = true ;
-
-               if ( ! partitions[i].name.empty() )
-                       names = true;
        }
 }
 
@@ -154,7 +145,11 @@ bool TreeView_Detail::set_selected( Gtk::TreeModel::Children rows,
        return false ;
 }
 
-void TreeView_Detail::create_row( const Gtk::TreeRow & treerow, const Partition & partition )
+void TreeView_Detail::create_row( const Gtk::TreeRow & treerow,
+                                  const Partition & partition,
+                                  bool & show_names,
+                                  bool & show_mountpoints,
+                                  bool & show_labels )
 {
        if ( partition .busy )
                treerow[ treeview_detail_columns .icon1 ] = 
@@ -179,6 +174,8 @@ void TreeView_Detail::create_row( const Gtk::TreeRow & treerow, const Partition
 
        // name
        treerow[treeview_detail_columns.name] = partition.name;
+       if ( ! partition.name.empty() )
+               show_names = true;
 
        if ( partition.filesystem == FS_LUKS && partition.busy )
        {
@@ -211,10 +208,15 @@ void TreeView_Detail::create_row( const Gtk::TreeRow & treerow, const Partition
                // mount point
                treerow[treeview_detail_columns.mountpoint] = Glib::build_path( ", ", 
partition.get_mountpoints() );
        }
+       if ( ! static_cast<Glib::ustring>( treerow[treeview_detail_columns.mountpoint] ).empty() )
+               show_mountpoints = true;
 
        //label
-       treerow[ treeview_detail_columns .label ] = partition.get_filesystem_label();
-               
+       Glib::ustring temp_filesystem_label = partition.get_filesystem_label();
+       treerow[treeview_detail_columns.label] = temp_filesystem_label;
+       if ( ! temp_filesystem_label.empty() )
+               show_labels = true;
+
        //size
        treerow[ treeview_detail_columns .size ] = Utils::format_size( partition .get_sector_length(), 
partition .sector_size ) ;
        


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