Dear all,

I'm writing a plugin for a software whose command prompt is in inside a
GTK+ GUI. My plugin is a set of C functions, most of them are supposed
to do computational stuff and one is supposed to create a GTK+ window
with an OSG drawing area for visualization. These functions are
collected in a shared library which is dynamically linked to the main
software (that one with the prompt inside a GTK+ GUI) at run-time (i.e.
the classical plugin functioning).

Now, I'm new to GTK+ development and the GUIs in general --I choose GTK+
because the main software itself uses GTK+, so I can avoid additional
dependencies for the GUI-- and also I'm moving my first steps in OSG.
Thus, as first thing, I've taken a look at osgviewerGTK and it works
very well: if I use gtk_main() as last instruction of the GUI build
function, all works fine.

However, gtk_main() starts a main loop for my visualization window and
this makes the command prompt of the main software unavailable to the
user, until the window is destroyed. So, I've changed gtk_main() to

    while (gtk_events_pending())
        gtk_main_iteration();

This would return the control to the prompt, but I then get a segfault:

Program received signal SIGSEGV, Segmentation fault.
0x00618c65 in gtk_widget_grab_focus () from /usr/lib/libgtk-x11-2.0.so.0
(gdb) c
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x01417ae4 in osgGA::EventQueue::getTime (this=0x2)
    at /usr/include/osgGA/EventQueue:183
183 double getTime() const { return osg::Timer::instance()->delta_s(_startTick, osg::Timer::instance()->tick()); }

I'm working on Ubuntu 10.04 32bit and I've used the following ld options
in my makefile: -losg -losgViewer -losgGA -losgDB -lpthread.

The first SIGSEGV occurs in libgtk and it seems to suggest that my
approach (changing gtk_main() with gtk_main_iteration()) is wrong.
However, I've tried the GTK+ Hello World described at
http://library.gnome.org/devel/gtk-tutorial/2.90/c39.html#SEC-HELLOWORLD
and it has worked as expected. Also I've tried to use VTK and the
GTK-VTK interface at http://vtkgtk.sourceforge.net/ in place of OSG and
apart from a problem with the drawing area (I got the same error by
using both gtk_main() and gtk_main_iteration(), so I think the interface
itself has some issue...) it also has worked as expected: no segfaults
and buttons up, running and responding. However I still would prefer to
use OSG instead of VTK.

IMHO there is a problem in the osgviewerGTK example class which appears
to be unusable unless it is used in classical GTK+ app. where gtk_main()
is required. If someone could give some advices on how to modify the class
OSGGTKDrawingArea to work in the situation described above, it would be
greatly appreciated.

Thanks in advance for those who have read until here :)

Regards,
--
Matteo
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to