Re: gtkmm 3.4.0 (gtk 3.4.2) multithread app graphic deterioration



On Sat, 7 Jul 2012 10:13:39 +0200
Giuseppe Penone <giuspen gmail com> wrote:
> Many thanks,
> Giuseppe.
> 
> 
> On Sat, Jul 7, 2012 at 9:14 AM, Kjell Ahlstedt
> <kjell ahlstedt bredband net>wrote:
> 
> > I don't know if this is any help, but anyway, have you seen these
> > comments at
> > http://developer.gnome.org/**gdk3/stable/gdk3-Threads.html<http://developer.gnome.org/gdk3/stable/gdk3-Threads.html>
> >
> > -- Unfortunately the above holds with the X11 backend only. With
> > the Win32 backend, GDK calls should not be attempted from multiple
> > threads at all.
> >
> > -- Before calling gdk_threads_leave() from a thread other than your
> > main thread, you probably want to call gdk_flush() to send all
> > pending commands to the windowing system.
> >
> > Kjell
> >
> > 2012-07-05 14:52, Giuseppe Penone skrev:
> >
> >  Hi,
> >> I'm writing a multithread app where different threads operate on
> >> the graphic.
> >> The non gui threads operate on graphic only after semaphores:
> >>
> >> gdk_threads_enter();
> >> OPERATION ON GUI FROM NON GUI THREAD
> >> gdk_threads_leave();
> >>
> >> and the gui thread is opened this way:
> >>
> >> g_thread_init(NULL);
> >> gdk_threads_init();
> >> Gtk::Main  kit(argc, argv);
> >> ...
> >> gdk_threads_enter();
> >> Gtk::Main::run(p_window);
> >> gdk_threads_leave();
> >>
> >> After some time the gui starts to deteriorate as in screenshot
> >> http://www.freeimagehosting.**net/hjltx<http://www.freeimagehosting.net/hjltx>(label
> >> over an icon, columns not expanding...). I have no clue about what
> >> could be wrong since there is no warning/error from the terminal
> >> while in the past when I missed a
> >> gdk_threads_enter/gdk_threads_**leave I had errors printed and the
> >> app crashed.
> >>
> >> Can anybody help me to understand where the error could be given
> >> the screenshot?
> >> I'm also considering porting the app back to gtkmm2 but since I
> >> use glade I'm afraid this will be not that easy.

Calling up the GDK global lock is not a good way to do it with gtkmm
because (amongst other things) libsigc++ is not thread safe.  You might
want to read the attachment to the now very old bug report at
https://bugzilla.gnome.org/show_bug.cgi?id=512348 for an explanation of
how to do it.  (The lack of priority given to threading issues might
also be something you want to consider.)

If you do want to use the global lock, you should in any event move the
call to gdk_threads_enter() so that the instantiation of Gtk::Main is
within it, as well as making sure that all access to libsigc++ objects
by multiple threads, including any unseen access arising from the
operation of sigc::trackable, are within a mutex (which might of
course be the global lock).

Chris


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