Store pointers to partition objects in TreeView_Details (#750168)
This stops copying of each displayed partition object into the TreeView_Details class. It also stops copy constructing lots of partition objects when just clicking on a partition in the disk graphic. The disk graphic needs to inform the main GUI and then the partition list which partition has been selected. The call sequence goes like: DrawingAreaVisualDisk::on_button_press_event(event) Win_GParted::on_partition_selected(partition_ptr, src_is_treeview) TreeView_Detail::set_selected(partition_ptr) TreeView_Detail::set_selected(rows, partition_ptr, inside_extended) Relevant source and highlighted comparison line: 140 bool TreeView_Detail::set_selected( Gtk::TreeModel::Children rows, 141 const Partition * partition_ptr, bool inside_extended ) 142 { 143 for ( unsigned int t = 0 ; t < rows .size() ; t++ ) 144 { >> 145 if ( static_cast<Partition>( rows[t][treeview_detail_columns.partition] ) == *partition_ptr ) 146 { 147 if ( inside_extended ) 148 expand_all() ; 149 150 set_cursor( static_cast<Gtk::TreePath>( rows[ t ] ) ) ; 151 return true ; 152 } 153 154 if ( set_selected( rows[t].children(), partition_ptr, true ) ) 155 return true ; 156 } 157 158 return false ; 159 } Then in this function the partition selected in the disk graphic (partition_ptr parameter) is compared in turn with each partition object stored in the Gtk::TreeView model to find the matching one to mark it as selected. This mere act of accessing the partition object stored in a row of the Gtk::TreeView model causes it to be copy constructed. So clicking on the 5th partition in the disk graphic will copy construct the first 5 partition objects just to do a compare to find the matching one. This is because it is not possible to get a reference from a Gtk:TreeViewProxy in gtkmm. Merely accessing a value in a Gtk::TreeView model takes a copy of that value. Subject: get a reference from a Gtk::TreeValueProxy http://comments.gmane.org/gmane.comp.gnome.gtkmm/2217 http://marc.info/?t=104400417500001&r=1&w=4 Bug 750168 - Reduce the amount of copying of partition objects
parent
c430acf5
Please register or sign in to comment