Re: GtkTextBuffer crashes



In short, I think that's it much better if you don't make GTK calls
from the second thread, it's a sure-fire way to avoid multi-threading
UI issues.  But, all you need to do is,

1. wrap gtk_main(), ie.,

  g_thread_init (NULL);   // Add this line
  gdk_threads_init ();   // Add this line
  gdk_threads_enter ();   // Add this line
  gtk_init (&argc, &argv);
  gtk_main ();   // Add this line
  gdk_threads_leave ();   // Add this line

2. In your second thread, make sure that every gtk/gdk call is wrapped,

  gdk_threads_enter ();   // Add this line
  gtk_do_something();
  gtk_do_something_else();
  gdk_threads_leave ();   // Add this line

Do NOT wrap GTK calls in the main thread, only in the second thread

On 15/10/2007, AlannY <m alanny ru> wrote:
Michael Lamothe wrote:
Hi AlannY,

I'm new to this mail thread but I think that I know what your issue
is.  Basically, GTK/GDK is not designed to be called from multiple at
the same time.  Doing so causes all kinds of strange issues such as
the ones that you are seeing.  There are many ways to get around this
issue but reading the information on
http://library.gnome.org/devel/gdk/stable/gdk-Threads.html is a great
start.

In general, I find it best never to make GTK/GDK calls from any thread
other than the main thread, although it is possible.

As stated earlier, I'm new to this mail list so if anyone would like
to correct me then please go ahead.

Hope that helps,

Michael


Not helps...




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