Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 March 11, 2008 23:09:07

z ..
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

vtk and gtk threads...


Hi,
I have a gtk/vtk program that uses vtkgtk package - vtkgtk.sf.net,
that itself uses gtkglext...

So I use an additional thread to make some computation and apply
changes on renderer,
and every second I render the image to the screen like this:
// render the image
gdk_threads_enter(); // Protect from gtk main loop
getInteractor()->Render();
gdk_flush();
gdk_threads_leave();

under Linux it works just perfect, but my fellows with windows say -
they got massive errors output as long as getInteractor()->Render();
is inside secondary thread, but if they move it to the main thread
everything works fine. The problem is - we need that it stays in the
secondary thread. Do you have an idea what could be the problem/workaround?
( I also put gdk_threads_enter();/leave(); around gtk_main() )

thank you in advance
Zeev Pekar
_______________________________________________
gtk-list mailing list
gtk-list@gnome.orghttp://mail.gnome.org/mailman/listinfo/gtk-list

Offline

#2 March 11, 2008 23:54:31

Tor L.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

vtk and gtk threads...


> under Linux it works just perfect,

Good for you then

> but my fellows with windows say - they got massive errors

As apparently needs to be said a couple of times a month on this list:
Don't use GTK+ from multiple threads if you intend your code to be
portable to Windows. I just doesn't work. And there is no easy fix for
this. See figure 1.

--tml
_______________________________________________
gtk-list mailing list
gtk-list@gnome.orghttp://mail.gnome.org/mailman/listinfo/gtk-list

Offline

#3 March 12, 2008 09:44:17

Tor L.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

vtk and gtk threads...


> can I generate an event inside this second thread that would call a
> callback that would draw to GTK+? would it work?

Well, it isn't that complex, no "events" involved. Just call
g_idle_add() in the other thread, passing it a callback function and a
pointer to input data for that callback function, and the callback
function will be called as soon as possible in the main thread (the
one running the GLib main loop, and by extension, the GTK+ event
processing (window message processing on Windows, X11 event processing
on X11)). Remember to return FALSE from the callback function so that
it won't be called repeatedly.

--tml
_______________________________________________
gtk-list mailing list
gtk-list@gnome.orghttp://mail.gnome.org/mailman/listinfo/gtk-list

Offline

#4 March 13, 2008 11:36:31

Tor L.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

vtk and gtk threads...


On 12/03/2008, <> wrote:
> Well, the program crashes
> ugly after a second or so, even on linux... Do you have an idea how to
> solve this issue?

Well, you just need to debug it and fix the rot cause for the crash ;)
Most likely some heap corruption error, referencing already freed (and
reused) memory, stuff like that. Check all your memory allocations and
deallocations, GObject reference counting, etc.

(Please try to keep this thread on the gtk-list where it started,
don't reply personally to me only)

--tml
_______________________________________________
gtk-list mailing list
gtk-list@gnome.orghttp://mail.gnome.org/mailman/listinfo/gtk-list

Offline

Board footer

Moderator control

Enjoy the 16th of December
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support