[gparted] Prevent flashing redraw of the devices combobox (#696149)



commit 52ee26f971a097c0f73b49cfd08d79198d376fd3
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Fri Aug 22 11:35:39 2014 +0100

    Prevent flashing redraw of the devices combobox (#696149)
    
    The device combobox was getting drawn blank, then getting drawn again
    with the selected device.  This was happening because at the start of
    Win_GParted::refresh_combo_devices() the GTK model behind the combobox,
    liststore_devices, was cleared, changing the active item, causing the
    combobox to get redrawn empty.  After the GTK model had been repopulated
    the active item was reset causing the comboxbox to get redrawn again,
    now showing the selected device.  Call flow:
    
        Win_GParted::refresh_combo_devices()
            liststore_devices->clear()
                //Gtk::Combobox emits signal_change.  Registered callbacks
                //called.
                    Win_GParted::combo_devices_changed()
                        Win_GParted::Refresh_Visual()
                            ...
            ...
            combo_devices.set_active(current_device);
                //Gtk::Combobox emits signal_change.  Registered callbacks
                //called.
                    Win_GParted::combo_devices_changed()
                        Win_GParted::Refresh_Visual()
                            ...
    
    This has always been the case, since the device combobox was first added
    to GParted before version 0.1 by commit:
    
        3a4b43e0adb3974dea656fcbe90d5e191e0e9784
        replaced deprecated OptionMenu with ComboBox ...
    
    Fix by temporarily blocking the devices comboxbox from emitting
    signal_changed while the GTK model behind the combobox is recreated.
    
    However, since automatic selection of the largest free space was added
    [1] in GParted 0.15.0, a more noticeable flashing redraw issue was
    caused in which the partition graphic and partition list were both drawn
    blank then redrawn fully populated.  Some distributions were not
    affected by this at all, some only experienced a single flash and others
    suffered from two or more flashing redraws.  Some affected
    distributions: CentOS 5.10, 6.5, 7.0, Debian 6, Fedora 14, 19, 20,
    Ubuntu 13.10, Xubuntu 14.04 LTS.  Did not occur on Kubuntu 12.04 LTS.
    
    [1] 5b53c12f6ee12312a9bacb44b8b05b12a540d3d6
        Select largest unallocated partition by default (#667365)
    
    Bug #696149 - Double refresh of display introduced with default
                  unallocated space

 include/Win_GParted.h |    1 +
 src/Win_GParted.cc    |   10 ++++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/include/Win_GParted.h b/include/Win_GParted.h
index 432e53a..3a554f4 100644
--- a/include/Win_GParted.h
+++ b/include/Win_GParted.h
@@ -209,6 +209,7 @@ private:
 
        //device combo
        Glib::RefPtr<Gtk::ListStore> liststore_devices ;
+       sigc::connection combo_devices_changed_connection;
 
        struct treeview_devices_Columns : public Gtk::TreeModelColumnRecord
        {
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index 1cf76e1..73d0297 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -300,7 +300,8 @@ void Win_GParted::init_toolbar()
        combo_devices .pack_start( treeview_devices_columns .device ) ;
        combo_devices .pack_start( treeview_devices_columns .size, false ) ;
        
-       combo_devices .signal_changed() .connect( sigc::mem_fun(*this, &Win_GParted::combo_devices_changed) );
+       combo_devices_changed_connection =
+               combo_devices .signal_changed() .connect( sigc::mem_fun(*this, 
&Win_GParted::combo_devices_changed) );
 
        hbox_toolbar .pack_start( combo_devices, Gtk::PACK_SHRINK ) ;
 }
@@ -577,6 +578,10 @@ void Win_GParted::init_hpaned_main()
 
 void Win_GParted::refresh_combo_devices()
 {
+       // Temporarily block the on change callback while re-creating the device list
+       // behind the combobox to prevent flashing redraw by being redrawn with an empty
+       // device list.
+       combo_devices_changed_connection .block();
        liststore_devices ->clear() ;
        
        menu = manage( new Gtk::Menu() ) ;
@@ -610,7 +615,8 @@ void Win_GParted::refresh_combo_devices()
                menu ->show_all() ;
                menubar_main .items()[ 0 ] .get_submenu() ->items()[ 1 ] .set_submenu( *menu ) ;
        }
-       
+
+       combo_devices_changed_connection .unblock();
        combo_devices .set_active( current_device ) ;
 }
 


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