Fixed inter-thread gdk_threads_enter()/gdk_threads_leave() protection.
authorshort <>
Sun, 9 Nov 2003 20:00:08 +0000 (20:00 +0000)
committershort <>
Sun, 9 Nov 2003 20:00:08 +0000 (20:00 +0000)
src/install/acquire/ui-gnome.c

index 2e8df89..57862bc 100644 (file)
@@ -586,6 +586,9 @@ gint reply;
                        (GnomeReplyCallback)on_DruidButtonOK_clicked_dialog_callback,
                        &reply);        /* data */
        g_signal_connect((gpointer)dialog,"close",G_CALLBACK(gtk_main_quit),NULL);
+       /* Never call gtk_main() from other thread than the initial one.
+        * We would have to switch GTK+ context (g_main_context()?).
+        */
        gtk_main();
        /* 'dialog' gets destroyed automatically */
        if (reply==0)   /* 0 for 'OK', 1 for 'Cancel', left -1 for dialog close. */
@@ -628,6 +631,8 @@ GtkTreeViewColumn *column;
 GtkCellRenderer *cell;
 GtkBox *druid_button_box;
 
+       gdk_threads_enter();
+
        App=GNOME_APP(create_App());
 
        DriversTreeView=GTK_TREE_VIEW(lookup_widget(GTK_WIDGET(App),"DriversTreeView"));
@@ -690,6 +695,8 @@ GtkBox *druid_button_box;
                        NULL);  /* callback_data */
 
        state_changed();
+
+       gdk_threads_leave();
 }
 
 static void ui_gnome_g_log_handler(const gchar *log_domain,GLogLevelFlags log_level,const gchar *message,gpointer user_data)
@@ -720,16 +727,14 @@ GtkWidget *dialog;
 
 static void ui_gnome_interactive(void)
 {
-       gtk_widget_show_all(GTK_WIDGET(App));
+       gdk_threads_enter();
 
-       if (!g_thread_supported())
-               g_thread_init(NULL);
-       if (!gdk_threads_mutex)
-               gdk_threads_init();
+       gtk_widget_show_all(GTK_WIDGET(App));
 
-       gdk_threads_enter();
        gtk_main();
+
        gdk_threads_leave();
+
        exit(EXIT_SUCCESS);
 }
 
@@ -742,6 +747,14 @@ gboolean ui_gnome_init(void)
        ui_interactive=ui_gnome_interactive;
        captivemodid_module_best_priority_notify=ui_gnome_module_best_priority_notify;
 
+       /* gdk_threads_init() must be called before gtk_init()!
+        * gtk_init() gets called by create_App() here.
+        */
+       if (!g_thread_supported())
+               g_thread_init(NULL);
+       if (!gdk_threads_mutex)
+               gdk_threads_init();
+
        /* Graphic widgets will all be hidden yet. */
        App_init();
        /* ui_gnome_g_log_handler() needs 'App'. */