Skip to content

Wrapping osgQt #7

@GoogleCodeExporter

Description

@GoogleCodeExporter
What steps will reproduce the problem?
1. Uncomment line 102 ( 'sys.exit()' ) in examples/osg-tutorial/osgViewerQt.py
2. Run the script above

What is the expected output? What do you see instead?
I would expect to see the same output from osgviewerQt example that comes with 
osgQt.  What I see however is a host of problems.

1) First you'll see a complaint about not being able to find base classes.
RuntimeError: extension class wrapper for base class QObject has not been 
created yet

I'm not very happy with my solution, but I ending up hacking boost::python.  To 
class.cpp (libs/python/src/object/class.cpp) I changed the get_class method to 
search the globals() dictionary.

   type_handle get_class(type_info id)
    {
        type_handle result(query_class(id));

        if (result.get() == 0)
        {
          PyObject* globals = PyEval_GetGlobals() ;
          PyObject* key = object( id.name() ).ptr() ;
          PyObject* obj = PyDict_GetItem( globals, key );
          if( obj ){
            return type_handle( obj->ob_type );
          }else{
            object report("extension class wrapper for base class ");
            report = report + id.name() + " has not been created yet";
            PyErr_SetObject(PyExc_RuntimeError, report.ptr());
            throw_error_already_set();
          }
        }
        return result;
    }

This got me past the error, but I reall wasn't sure where this was going to 
break down.

2) To exercise the feature I tried to translate osgviewerQt.cpp ( in 
OpenSceneGraph-3.0.1/examples/osgviewerQt/osgviewerQt.cpp ), which is where 
osgBoostPython/examples/osg-tutorial/osgViewerQt.py comes from.

At first I tried to inherit from both QWidget and osgViewer.CompositeWindow and 
I get the following error :
TypeError: metaclass conflict: the metaclass of a derived class must
    be a (non-strict) subclass of the metaclasses of all its bases

After reading up on metaclasses ( here's a great reference 
http://www.ibm.com/developerworks/linux/library/l-pymeta2/ ) I tried to 
set the metaclass manually and got the following error :

TypeError: multiple bases have instance lay-out conflict

This is when I gave up on multiple inheritance and decided to simply inherit 
from QWidget and include CompositeViewer as a member.  This 
results in a segfault and even after linking against the debug builds
of python, boost::python, and osgQt the traceback from gdb "hints" at 
the call to QWidget::show .

Need to move on for the time being, but I hope to come back to this soon.
I've attached the traceback and if anyone sees something that might point 
at a solution, please let me know.

Original issue reported on code.google.com by alex.r.o...@gmail.com on 13 Jan 2012 at 9:04

Attachments:

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions