From Jordi Torres, "We have a code using gcc with -Wextra flag and using OSG as a third party library. It does not compile when importing <osgViewer/Viewer> failing in EventHandler and GUIEventHandler:
.... GUIEventHandler: In copy constructor 'osgGA::GUIEventHandler::GUIEventHandler(const osgGA::GUIEventHandler&, const osg::CopyOp&)': /include/osgGA/GUIEventHandler:56:9: error: base class 'class osg::Object' should be explicitly initialized in the copy constructor [-Werror=extra] It seems the diamond problem: A = osg::Object / \ / \--> Virtual inheritance B C \ / \ / D = EventHandler | | E = GUIEventHandler The most derived class(E) handles the instantiation of A (osg::Object), but all have to be responsible in case they are the ones instantiated. In case A is not initialized in the copy constructor of derived classes the default constructor will be called, which seems a bug. I've added osg::Object to the initalization list of EventHandler and GUIEventHandler copy constructors, because both classes are instantiables. "
This commit is contained in:
parent
354d79acd1
commit
e04e03d695
@ -37,6 +37,7 @@ public:
|
|||||||
|
|
||||||
EventHandler() {}
|
EventHandler() {}
|
||||||
EventHandler(const EventHandler& eh,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
|
EventHandler(const EventHandler& eh,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
|
||||||
|
osg::Object(eh,copyop),
|
||||||
osg::NodeCallback(eh, copyop),
|
osg::NodeCallback(eh, copyop),
|
||||||
osg::Drawable::EventCallback(eh, copyop) {}
|
osg::Drawable::EventCallback(eh, copyop) {}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ public:
|
|||||||
#if 1
|
#if 1
|
||||||
GUIEventHandler() {}
|
GUIEventHandler() {}
|
||||||
GUIEventHandler(const GUIEventHandler& eh,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
|
GUIEventHandler(const GUIEventHandler& eh,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
|
||||||
EventHandler(eh, copyop) {}
|
osg::Object(eh, copyop), EventHandler(eh, copyop) {}
|
||||||
#else
|
#else
|
||||||
GUIEventHandler() : _ignoreHandledEventsMask(GUIEventAdapter::NONE) {}
|
GUIEventHandler() : _ignoreHandledEventsMask(GUIEventAdapter::NONE) {}
|
||||||
GUIEventHandler(const GUIEventHandler& eh,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
|
GUIEventHandler(const GUIEventHandler& eh,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
|
||||||
|
Loading…
Reference in New Issue
Block a user