|
I understand about there not being enough
information, and I apologize about this. Since I am so new to OSG, I assumed I
was doing something wrong that was common for beginners. I tried what you asked and I am getting
the same crash at the same place. Am I declaring my derived EventHandler class
correctly: class EventHandler : public
osgGA::GUIEventHandler { public: EventHandler() {} protected: virtual ~EventHandler() {} //
Thanks Thomas public: virtual bool handle(const
osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa) { return osgGA::GUIEventHandler::handle(ea,
aa); } }; From:
[EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On
Behalf Of Don Burns Hi Jeff, On 8/21/06, Jeff
Kershner <[EMAIL PROTECTED]>
wrote: I have an EventHandler publicly derived from
osgGA::GUIEventHandler (as well as I made sure there the destructor is
virtual). I dynamically create an instance of my EventHandler class like
this: osg::ref_ptr<osgGA::GUIEventHandler> eh(new
EventHandler()); m_Viewer.getEventHandlerList().push_front(eh); My derived handle function is getting called correctly and
everything seems to work. But when I exit out of my application I get an
'Unhandled exception.' My call stack in telling me the following: MyApplicationName!EventHandler::`scalar deleting
destructor'() + 0x42 MyApplicationName!EventHandler::`scalar deleting
destructor'() + 0x5b Any ideas? From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
On Behalf Of Don Burns
Any time you call "new" you are dynamically
allocating memory. So.... now I'm lost, what was the original question? On
8/21/06, Jeff Kershner <[EMAIL PROTECTED]>
wrote: That was the original allocation… but then I changed to this: osg::ref_ptr<osgGA::GUIEventHandler> eh(new
EventHandler()); m_Viewer.getEventHandlerList().push_front(eh); From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
On Behalf Of Don Burns
What is this: On
8/21/06, Jeff Kershner <[EMAIL PROTECTED]>
wrote: Nothing is dynamically allocated in my test app and so I am
not freeing or deleting anything. From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
On Behalf Of Don Burns
Are you freeing something that was already being
managed by a ref_ptr? On
8/21/06, Jeff Kershner <[EMAIL PROTECTED]>
wrote: Thanks for the reply: So now I declared my derived event handler class like this: osg::ref_ptr<osgGA::GUIEventHandler> eh(new
EventHandler()); m_Viewer.getEventHandlerList().push_front(eh); But I am getting a crash in the msvcr71d.dll in free.c.
I believe the error I am getting is this: `scalar deleting destructor'() + 0x42 `scalar deleting destructor'() + 0x5b So this is either MSVC++ 7.1 telling me that it is breaking
on what it thinks to be a memory leak, or it is actually trying to free
something that has already been freed. Since this crash only happens when
I run with the debugger, I am leaning towards the first… Any ideas? From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
On Behalf Of Don Burns Hi Jeff, On
8/16/06, Jeff Kershner <[EMAIL PROTECTED]>
wrote: I have an event handler class like this: class EventHandler : public osgGA::GUIEventHandler { public:
virtual bool handle(const osgGA::GUIEventAdapter& ea,
osgGA::GUIActionAdapter& aa); }; The handle function just calls the base class' handle
function… This is how it is implemented: EventHandler* pEventHandler = new EventHandler(); m_Viewer.getEventHandlerList().push_front(pEventHandler); When my application exits, I get a memory leak that is caused
by this EventHandler. Do I need to delete this EventHandler pointer? It feels weird to delete a pointer that I am handing to
another system… Finally, as a side note, does the EventHandler class that I
create need to have a virtual destructor explicitly written? Thanks, /jk
|
_______________________________________________ osg-users mailing list [email protected] http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/
