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 <[EMAIL PROTECTED]> 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... > ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GtkTextBuffer crashes
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 On 15/10/2007, AlannY <[EMAIL PROTECTED]> wrote: > AlannY wrote: > > Hi there. > > > > I have trouble in my program. > > > > First of all, I'm using latest GTK and got many assertion in console > > when using GtkTextBuffer. > > > > Second. I have 2 threads. First one is a gtk_main_loop. Second one is my > > (pthread) thread. In second thread I'm trying to set this: > > > > gtk_text_buffer_set_text(window.buffer, "", -1); > > gtk_text_buffer_get_start_iter(window.buffer, &iter); > > gtk_text_buffer_insert_with_tags(window.buffer, &iter, "Some text", -1, > > bold, NULL); > > gtk_text_buffer_insert_at_cursor(window.buffer, "Another text", -1); > > > > Then I got many assertions, aborts and segmentation faults: > > > > Gtk-ERROR **: file gtktextlayout.c: line 1113 (get_style): assertion > > failed: (layout->one_style_cache == NULL) > > Gtk-CRITICAL **: gtk_text_layout_real_invalidate: assertion > > `layout->wrap_loop_count == 0' failed > > > > Is there any idea on how to solve this problem? > > ___ > > gtk-app-devel-list mailing list > > gtk-app-devel-list@gnome.org > > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > > > > Also I have that error: > > Gtk-WARNING **: Invalid text buffer iterator: either the iterator is > uninitialized, or the characters/pixbufs/widgets in the buffer have been > modified since the iterator was created. > You must use marks, character numbers, or line numbers to preserve a > position across buffer modifications. > You can apply tags and insert marks without invalidating your iterators, > but any mutation that affects 'indexable' buffer contents (contents that > can be referred to by character offset) > will invalidate all outstanding iterators > ___ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GtkTextBuffer crashes
AlannY wrote: > Hi there. > > I have trouble in my program. > > First of all, I'm using latest GTK and got many assertion in console > when using GtkTextBuffer. > > Second. I have 2 threads. First one is a gtk_main_loop. Second one is my > (pthread) thread. In second thread I'm trying to set this: > > gtk_text_buffer_set_text(window.buffer, "", -1); > gtk_text_buffer_get_start_iter(window.buffer, &iter); > gtk_text_buffer_insert_with_tags(window.buffer, &iter, "Some text", -1, > bold, NULL); > gtk_text_buffer_insert_at_cursor(window.buffer, "Another text", -1); > > Then I got many assertions, aborts and segmentation faults: > > Gtk-ERROR **: file gtktextlayout.c: line 1113 (get_style): assertion > failed: (layout->one_style_cache == NULL) > Gtk-CRITICAL **: gtk_text_layout_real_invalidate: assertion > `layout->wrap_loop_count == 0' failed > > Is there any idea on how to solve this problem? > ___ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > Also I have that error: Gtk-WARNING **: Invalid text buffer iterator: either the iterator is uninitialized, or the characters/pixbufs/widgets in the buffer have been modified since the iterator was created. You must use marks, character numbers, or line numbers to preserve a position across buffer modifications. You can apply tags and insert marks without invalidating your iterators, but any mutation that affects 'indexable' buffer contents (contents that can be referred to by character offset) will invalidate all outstanding iterators ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list