Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrapping osgQt #7

Open
GoogleCodeExporter opened this issue Mar 14, 2015 · 0 comments
Open

Wrapping osgQt #7

GoogleCodeExporter opened this issue Mar 14, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

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 [email protected] on 13 Jan 2012 at 9:04

Attachments:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant