Changeset 13758


Ignore:
Timestamp:
Jan 4, 2013, 6:57:39 AM (8 years ago)
Author:
jordan
Message:

(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.

Location:
trunk/gtk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/main.c

    r13757 r13758  
    885885}
    886886
     887struct session_close_struct
     888{
     889  tr_session * session;
     890  struct cbdata * cbdata;
     891};
     892
     893/* since tr_sessionClose () is a blocking function,
     894 * delegate its call to another thread here... when it's done,
     895 * punt the GUI teardown back to the GTK+ thread */
    887896static gpointer
    888897session_close_threadfunc (gpointer gdata)
    889898{
    890   /* since tr_sessionClose () is a blocking function,
    891    * call it from another thread... when it's done,
    892    * punt the GUI teardown back to the GTK+ thread */
    893   struct cbdata * cbdata = gdata;
    894   gdk_threads_enter ();
    895   gtr_core_close (cbdata->core);
    896   gdk_threads_add_idle (on_session_closed, gdata);
    897   gdk_threads_leave ();
     899  struct session_close_struct * data = gdata;
     900  tr_sessionClose (data->session);
     901  gdk_threads_add_idle (on_session_closed, data->cbdata);
     902  g_free (data);
    898903  return NULL;
    899904}
     
    910915  GtkWidget *r, *p, *b, *w, *c;
    911916  struct cbdata *cbdata = vdata;
     917  struct session_close_struct * session_close_data;
    912918
    913919  /* stop the update timer */
     
    961967
    962968  /* shut down libT */
    963   g_thread_new ("shutdown-thread", session_close_threadfunc, vdata);
     969  session_close_data = g_new (struct session_close_struct, 1);
     970  session_close_data->cbdata = cbdata;
     971  session_close_data->session = gtr_core_close (cbdata->core);
     972  g_thread_new ("shutdown-thread", session_close_threadfunc, session_close_data);
    964973}
    965974
  • trunk/gtk/tr-core.c

    r13729 r13758  
    872872}
    873873
    874 void
     874tr_session *
    875875gtr_core_close (TrCore * core)
    876876{
     
    881881      core->priv->session = NULL;
    882882      gtr_pref_save (session);
    883       tr_sessionClose (session);
    884     }
     883    }
     884
     885  return session;
    885886}
    886887
  • trunk/gtk/tr-core.h

    r13683 r13758  
    7070TrCore *       gtr_core_new (tr_session *);
    7171
    72 void           gtr_core_close (TrCore*);
     72tr_session *   gtr_core_close (TrCore*);
    7373
    7474/* Return the model used without incrementing the reference count */
Note: See TracChangeset for help on using the changeset viewer.