From e04e03d695e4b0ffa3f43338b356bc461b370023 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 17 Jan 2014 13:59:29 +0000 Subject: [PATCH] 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 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. " --- include/osgGA/EventHandler | 1 + include/osgGA/GUIEventHandler | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/osgGA/EventHandler b/include/osgGA/EventHandler index 956b88766..606b6e386 100644 --- a/include/osgGA/EventHandler +++ b/include/osgGA/EventHandler @@ -37,6 +37,7 @@ public: EventHandler() {} EventHandler(const EventHandler& eh,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY): + osg::Object(eh,copyop), osg::NodeCallback(eh, copyop), osg::Drawable::EventCallback(eh, copyop) {} diff --git a/include/osgGA/GUIEventHandler b/include/osgGA/GUIEventHandler index e9d6dc636..547cd3625 100644 --- a/include/osgGA/GUIEventHandler +++ b/include/osgGA/GUIEventHandler @@ -54,7 +54,7 @@ public: #if 1 GUIEventHandler() {} GUIEventHandler(const GUIEventHandler& eh,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY): - EventHandler(eh, copyop) {} + osg::Object(eh, copyop), EventHandler(eh, copyop) {} #else GUIEventHandler() : _ignoreHandledEventsMask(GUIEventAdapter::NONE) {} GUIEventHandler(const GUIEventHandler& eh,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):