Re: Application suddenly stuck at startup



Hi,

On 03/02/2013 04:16 AM, Andrey Gursky wrote:
2013/3/2, Robert Schroll <rschroll gmail com>:
On Fri, Mar 1, 2013 at 7:14 PM, Andrey Gursky <andrey gursky e-mail ua>
wrote:
Hi Robert, Jonathan,

2013/3/1, Robert Schroll <rschroll gmail com>:  I agree with your
reading of the docs.  It's things like this that
  leave me perpetually confused about threading.  The one possible
  explanation I see is that "activate" is a signal of GApplication,
not
  GtkApplication.  It could be that GLib signal handlers run outside
of
  the Gdk lock, while Gtk signal handlers run inside.

  Hopefully someone who actually understands all of this will comment.

Robert, you're right regarding GLib vs GTK callbacks!

So, I understand I would have to held the GDK lock for GLib callbacks but not for the GTK ones, that makes sense.

Robert was also right, the "activate" signal is from GApplication, not from GtkApplication. That's why (I guess?) that the lock should be held before handling things related to Gtk. This is actually documented in the GtkApplication's description [1].

So that was my fault for not reading everything completely.

 Re: Clarification of GTK/GDK locking pre GTK 4.0
    http://thread.gmane.org/gmane.comp.gnome.gtk+.general/24817/focus=24834

Eh.
I've been reading the whole thread, as well as other threads on the group, and I'm not sure the situation is clarified in my head... :-) Some says Gdk.thread_* functions are deprecated and everything touching Gtk should run in the main thread, some says GLib.idle_add is running in the main thread and it's OK but maybe not...

So, say my application is not using any threads (it doesn't create threads on its own):

* should I still call Gdk.theads_init()?
* is it safe to use GLib.idle_add() & co? If no, in which context is it unsafe? * must I use Gdk.threads_add_* & co? If yes, in which context must I use them? * is it safe to assume that all my code is running in the main thread, and that I can skip using Gdk.threads_* API and that I also don't have to use GLib.idle_add API to schedule modifications to my Gtk widgets? [2]

(... probably other questions coming soon).

Actually, is there a document which explains "what are the good practices for writing Gtk application (wrt. threads)?"

Regards,

 Jon


[1]: http://developer.gnome.org/gtk3/unstable/GtkApplication.html#GtkApplication.description

[2]: in lot of places, my application was using lines like:

   GLib.idle_add(gtk_entry.set_text, "foo bar")

and I was wondering wtf they were doing this. I start to form something in my head which looks like the beginning of some understanding of this. I'm still not sure though.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]