[gparted] Make GParted exit when closed before the initial load completes (#771816)
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Make GParted exit when closed before the initial load completes (#771816)
- Date: Wed, 5 Oct 2016 18:59:11 +0000 (UTC)
commit 7ea22f1190eb22fb50ca6829be1d6b30ace2fb46
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Wed Sep 21 13:49:02 2016 +0100
Make GParted exit when closed before the initial load completes (#771816)
If the GParted main window is closed before the initial device load
completed gpartedbin never exits. The main window closes but the
process sits there idle forever. Subsequently running GParted reports
this error:
# gparted
The process gpartedbin is already running.
Only one gpartedbin process is permitted.
If the user is running GParted from a desktop menu they will never see
this error so they will never know why GParted won't start any more.
More technically, it is if the main window is closed before the
Win_GParted::on_show() callback completes.
I assume the Gtk main loop doesn't setup the normal quit handling until
the on_show() callback finishes drawing the main window for the first
time. Following this hint [1], move the initial device load from the
on_show() callback to immediately after it completes by using a run once
idle callback setup in on_show().
This looks exactly the same to the user except now gpartedbin exits when
the main window is closed during the initial device load. Note that
GParted finished the device load before exiting. This is exactly the
same as happens when exiting during subsequent device refreshes.
[1] How to know when a Gtk Window is fully shown?
http://stackoverflow.com/questions/14663212/how-to-know-when-a-gtk-window-is-fully-shown
"If you want to know when your main window appears the first time,
it is far easier (and saner) add a g_idle_add after your show_all
call."
Bug 771816 - GParted never exits if the main window is closed before the
initial device load completes
include/Win_GParted.h | 3 ++-
src/Win_GParted.cc | 17 +++++++++++++++--
2 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/include/Win_GParted.h b/include/Win_GParted.h
index 01db5f2..4cb9ef4 100644
--- a/include/Win_GParted.h
+++ b/include/Win_GParted.h
@@ -153,7 +153,8 @@ private:
void radio_devices_changed( unsigned int item ) ;
bool on_delete_event( GdkEventAny* ) ;
void on_show() ;
-
+
+ static gboolean initial_device_refresh( gpointer data );
void menu_gparted_refresh_devices();
void menu_gparted_features();
void menu_gparted_quit();
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index 44c7102..e226f76 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -1392,9 +1392,22 @@ void Win_GParted::on_show()
vpaned_main .set_position( vpaned_main .get_height() ) ;
close_operationslist() ;
- menu_gparted_refresh_devices() ;
+ // Register callback for as soon as the main window has been shown to perform the
+ // first load of the disk device details. Do it this way because the Gtk::main
+ // loop doesn't seem to enable quit handling until on_show(), this function, has
+ // drawn the main window for the first time and returned, and we want Close Window [Alt-quit to work
+ // during the initial load of the disk device details.
+ g_idle_add( initial_device_refresh, this );
}
-
+
+// Callback used to load the disk device details for the first time
+gboolean Win_GParted::initial_device_refresh( gpointer data )
+{
+ Win_GParted *win_gparted = static_cast<Win_GParted *>( data );
+ win_gparted->menu_gparted_refresh_devices();
+ return false; // one shot g_idle_add() callback
+}
+
void Win_GParted::menu_gparted_refresh_devices()
{
show_pulsebar( _("Scanning all devices...") ) ;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]