1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-01-31 03:12:44 +00:00

(gtk) #5203 transmission-gtk shouldn't use gdk_threads_enter() and gdk_threads_leave() -- on shutdown, destruct the TrCore GObject in the glib thread, and then call tr_sessionClose() from a worker thread.

This commit is contained in:
Jordan Lee 2013-01-04 06:57:39 +00:00
parent 4e0ffffbf0
commit 5877747ad6
3 changed files with 22 additions and 12 deletions

View file

@ -884,17 +884,22 @@ on_session_closed (gpointer gdata)
return FALSE;
}
struct session_close_struct
{
tr_session * session;
struct cbdata * cbdata;
};
/* since tr_sessionClose () is a blocking function,
* delegate its call to another thread here... when it's done,
* punt the GUI teardown back to the GTK+ thread */
static gpointer
session_close_threadfunc (gpointer gdata)
{
/* since tr_sessionClose () is a blocking function,
* call it from another thread... when it's done,
* punt the GUI teardown back to the GTK+ thread */
struct cbdata * cbdata = gdata;
gdk_threads_enter ();
gtr_core_close (cbdata->core);
gdk_threads_add_idle (on_session_closed, gdata);
gdk_threads_leave ();
struct session_close_struct * data = gdata;
tr_sessionClose (data->session);
gdk_threads_add_idle (on_session_closed, data->cbdata);
g_free (data);
return NULL;
}
@ -909,6 +914,7 @@ on_app_exit (gpointer vdata)
{
GtkWidget *r, *p, *b, *w, *c;
struct cbdata *cbdata = vdata;
struct session_close_struct * session_close_data;
/* stop the update timer */
if (cbdata->timer)
@ -960,7 +966,10 @@ on_app_exit (gpointer vdata)
gtr_pref_int_get (TR_KEY_main_window_y));
/* shut down libT */
g_thread_new ("shutdown-thread", session_close_threadfunc, vdata);
session_close_data = g_new (struct session_close_struct, 1);
session_close_data->cbdata = cbdata;
session_close_data->session = gtr_core_close (cbdata->core);
g_thread_new ("shutdown-thread", session_close_threadfunc, session_close_data);
}
static void

View file

@ -871,7 +871,7 @@ gtr_core_new (tr_session * session)
return core;
}
void
tr_session *
gtr_core_close (TrCore * core)
{
tr_session * session = gtr_core_session (core);
@ -880,8 +880,9 @@ gtr_core_close (TrCore * core)
{
core->priv->session = NULL;
gtr_pref_save (session);
tr_sessionClose (session);
}
return session;
}
/***

View file

@ -69,7 +69,7 @@ GType tr_core_get_type (void) G_GNUC_CONST;
TrCore * gtr_core_new (tr_session *);
void gtr_core_close (TrCore*);
tr_session * gtr_core_close (TrCore*);
/* Return the model used without incrementing the reference count */
GtkTreeModel * gtr_core_model (TrCore * self);