Hello,
I'm having memory woes.
I've got a C++ Library (Equalizer from Eyescale) and they use the Traversal
Visitor Pattern to allow you to add new functionality to their classes.
I've finally figured out how it works, and I've got a Visitor that just
returns the properties from one of the objects. (since I don't know how
they're allocated).
so.
My little code does this:
VisitorResult AGLContextVisitor::visit( Channel* channel )
{
// Search through Nodes, Pipes until we get to the right window.
// Add some code to make sure we find the right one?
// Not executing the following code as C++ in gdb?
eq::Window* w = channel->getWindow();
OSWindow* osw = w->getOSWindow();
AGLWindow* aw = (AGLWindow *)osw;
AGLContext agl_ctx = aw->getAGLContext();
this->setContext(agl_ctx);
return TRAVERSE_PRUNE;
}
So here's the problem.
eq::Window* w = channel->getWindow();
(gdb) print w
0x0
BUT If I do this:
(gdb) set objc-non-blocking-mode off
(gdb) print w=channel->getWindow()
0x300effb9
// an honest memory location, and sets w as verified in the Debugger window
of XCode.
It does the same thing for osw.
I don't get it. Why would something work in (gdb) but not in the code?
The file is completely a cpp file, but it seems to be running in objc++,
since I need to turn blocking off.
Help!? I feel like I'm missing some memory-management basic thing here,
either with C++ or Obj-C.
[edit]
channel-getWindow() is supposed to do this:
/** @return the parent window. @version 1.0 */
Window* getWindow() { return _window; }
The code also executes fine if I run it from a C++-only application.
[edit]
No... I tried creating a simple stand-alone program since I was tired of running it as a plugin. Messy to debug.
And no, it doesn't run in the C++ program either. So I'm really at a loss as to what I'm doing wrong.
Thanks,
--
Stephen Furlani