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:

    3a4b43e0ad
    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] 5b53c12f6e
    Select largest unallocated partition by default (#667365)

Bug #696149 - Double refresh of display introduced with default
              unallocated space
This commit is contained in:
Mike Fleetwood 2014-08-22 11:35:39 +01:00 committed by Curtis Gedak
parent 7f99b69c64
commit 52ee26f971
2 changed files with 9 additions and 2 deletions

View File

@ -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
{

View File

@ -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 ) ;
}