From 57a7895ead055ba182a93d766ee6b6b74a7a91d8 Mon Sep 17 00:00:00 2001 From: Qball Cow Date: Sun, 7 Dec 2008 11:47:13 +0100 Subject: [PATCH] Remove the gdk_thread_enter stuff from the plugin, and put thread unsafe in idle call (aka hang in mainloop->mainn thread --- src/magnatune.c | 9 +++++---- src/plugin.c | 31 +++++++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/magnatune.c b/src/magnatune.c index 403c3a9..8e7857c 100644 --- a/src/magnatune.c +++ b/src/magnatune.c @@ -12,7 +12,8 @@ static void magnatune_cleanup_xml(); static axlDoc *magnatune_xmldoc = NULL; GMutex *mt_db_lock = NULL; - +/* hack fix this */ +int magnatune_end_download(); /** * Makes a copy with all &#; decoded @@ -323,9 +324,9 @@ void magnatune_db_download_xml_thread(gpointer data) g_free(dld); - gdk_threads_enter(); - magnatune_end_download(); - gdk_threads_leave(); + + g_idle_add(magnatune_end_download, NULL); + } void magnatune_db_download_xml(ProgressCallback cb, gpointer data ) { diff --git a/src/plugin.c b/src/plugin.c index 9d7bc03..2cbff89 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -474,19 +474,40 @@ static void magnatune_unselected(GtkWidget *container) gtk_container_remove(GTK_CONTAINER(container), magnatune_vbox); } -void magnatune_end_download() +int magnatune_end_download() { downloading = FALSE; magnatune_get_genre_list(); gtk_widget_hide(magnatune_pb); gtk_widget_set_sensitive(glade_xml_get_widget(pl3_xml, "pl3_win"), TRUE); + return FALSE; } + +typedef struct _Pass{ + GtkWidget *pb; + int download; + int total; +}Pass; + +static int magnatune_download_xml_callback_real(Pass *p); +/* Move it to main thread, by pushing in idle */ static void magnatune_download_xml_callback(int download, int total,gpointer data) { - GtkWidget *pb = data; + Pass *p= g_malloc0(sizeof(*p)); + p->pb = data; + p->download = download; + p->total =total; + g_idle_add(magnatune_download_xml_callback_real, p); +} + +static int magnatune_download_xml_callback_real(Pass *p) +{ + GtkWidget *pb = p->pb; + int download = p->download; + int total = p->total; gchar *label = NULL; - gdk_threads_enter(); +// gdk_threads_enter(); if(total > 0) gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(pb), download/(float)total); else @@ -507,7 +528,9 @@ static void magnatune_download_xml_callback(int download, int total,gpointer dat g_free(label); // while(gtk_events_pending()) // gtk_main_iteration(); - gdk_threads_leave(); +// gdk_threads_leave(); + g_free(p); + return FALSE; } static void magnatune_download() -- 2.11.4.GIT