Move threading model back to GMainLoop one; Gnome subsystems are too buggy.
authorshort <>
Wed, 12 Nov 2003 06:24:30 +0000 (06:24 +0000)
committershort <>
Wed, 12 Nov 2003 06:24:30 +0000 (06:24 +0000)
src/install/acquire/ui-gnome.c

index 32b2150..d565f69 100644 (file)
 
 /* Config: */
 #define PROGRESS_UPDATE_USEC 200000
+/* Although proper GTK+ locking is provided below there are some
+ * bugs with compatibility of GTK+/Gnome-VFS/GConf.
+ * The main thread executes gtk_main()->g_main_loop_run()
+ * while the working thread initializes Gnome-VFS by GConf and
+ * executes also g_main_loop_run() while sharing some poll() fds.
+ */
+/* #define UI_GNOME_THREADS 1 */
 
 
 static GnomeApp *App;
@@ -266,6 +273,13 @@ static gchar *uri_text=NULL;
                        }
                }
 
+#ifndef UI_GNOME_THREADS
+       while (g_main_context_pending(NULL))
+               g_main_context_iteration(
+                               NULL,   /* context */
+                               FALSE); /* may_block */
+#endif /* UI_GNOME_THREADS */
+
        gdk_flush();
        gdk_threads_leave();
 
@@ -377,6 +391,7 @@ gchar *text;
 
 typedef void (*process_t)(void);
 
+#ifdef UI_GNOME_THREADS
 /* 'GThreadFunc' type. */
 gpointer execute_process_func(process_t process /* data */)
 {
@@ -391,13 +406,17 @@ gpointer execute_process_func(process_t process /* data */)
 
        return NULL;
 }
+#endif /* UI_GNOME_THREADS */
 
 /* We are called inside gdk_threads_enter(). */
 static void execute_process(process_t process)
 {
+#ifdef UI_GNOME_THREADS
 GThread *gthread;
+#endif /* UI_GNOME_THREADS */
 
        progress_start();
+#ifdef UI_GNOME_THREADS
        gthread=g_thread_create_full(
                        (GThreadFunc)execute_process_func,      /* func */
                        process,        /* data */
@@ -411,6 +430,9 @@ GThread *gthread;
         * locked if the 'process' func did not finish yet.
         */
        g_thread_join(gthread);
+#else /* UI_GNOME_THREADS */
+       (*process)();
+#endif /* UI_GNOME_THREADS */
        progress_end();
 }
 
@@ -759,6 +781,7 @@ gboolean ui_gnome_init(void)
        ui_interactive=ui_gnome_interactive;
        captivemodid_module_best_priority_notify=ui_gnome_module_best_priority_notify;
 
+#ifdef UI_GNOME_THREADS
        /* gdk_threads_init() must be called before gtk_init()!
         * gtk_init() gets called by create_App() here.
         */
@@ -766,6 +789,7 @@ gboolean ui_gnome_init(void)
                g_thread_init(NULL);
        if (!gdk_threads_mutex)
                gdk_threads_init();
+#endif /* UI_GNOME_THREADS */
 
        /* Graphic widgets will all be hidden yet. */
        App_init();