gfx points to an object in stack. Are you sure that the object is still there (at the same position where it was) when you are trying to draw?
Tronic
2010-03-07 03:18:35
gfx points to an object in stack. Are you sure that the object is still there (at the same position where it was) when you are trying to draw?
It's bad practice to store pointer to argument given to you as a reference - this creates confusion about memory ownership. Either make a copy of the referenced object (if it's a value class), or change the method to take smart pointer (like boost::shared_ptr
) to the shared resource. This way the resource ownership management is explicit.
To your immediate issue - the Graphics
instance is probably allocated on the stack and goes out of scope, thus destructed. Then your Picture
code references dead object.