[eog] Make sure to only reuse an empty window if it is done initializing



commit 92c37ff6b34a2866ba2d03be7f6e1e973c707419
Author: Felix Riemann <friemann gnome org>
Date:   Mon Jun 4 21:55:29 2012 +0200

    Make sure to only reuse an empty window if it is done initializing
    
    This avoids a race condition when opening images through multiple instances.
    The second instance could then override the already loading (hidden)
    window's image resulting in only one image window showing.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=677200

 src/eog-application.c |    3 ++-
 src/eog-window.c      |    8 ++++++++
 src/eog-window.h      |    1 +
 3 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/src/eog-application.c b/src/eog-application.c
index e666f6d..dcef875 100644
--- a/src/eog-application.c
+++ b/src/eog-application.c
@@ -216,7 +216,8 @@ eog_application_get_empty_window (EogApplication *application)
 	for (l = windows; l != NULL; l = l->next) {
 		EogWindow *window = EOG_WINDOW (l->data);
 
-		if (eog_window_is_empty (window)) {
+		/* Make sure the window is empty and not initializing */
+		if (eog_window_is_empty (window) && eog_window_was_initialized (window)) {
 			empty_window = window;
 			break;
 		}
diff --git a/src/eog-window.c b/src/eog-window.c
index ca04bab..58f572e 100644
--- a/src/eog-window.c
+++ b/src/eog-window.c
@@ -5700,3 +5700,11 @@ eog_window_reload_image (EogWindow *window)
 	eog_thumb_view_select_single (EOG_THUMB_VIEW (window->priv->thumbview),
 				      EOG_THUMB_VIEW_SELECT_CURRENT);
 }
+
+gboolean
+eog_window_was_initialized (const EogWindow *window)
+{
+	g_return_val_if_fail (EOG_IS_WINDOW (window), FALSE);
+
+	return window->priv->status == EOG_WINDOW_STATUS_NORMAL;
+}
diff --git a/src/eog-window.h b/src/eog-window.h
index 00ce93a..b4c3a05 100644
--- a/src/eog-window.h
+++ b/src/eog-window.h
@@ -124,6 +124,7 @@ void          eog_window_open_file_list	(EogWindow       *window,
 					 GSList          *file_list);
 
 gboolean      eog_window_is_empty 	(EogWindow       *window);
+gboolean      eog_window_was_initialized (const EogWindow *window);
 
 void          eog_window_reload_image (EogWindow *window);
 EogDialog    *eog_window_get_properties_dialog (EogWindow *window);



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