← Back to team overview

yade-dev team mailing list archive

Re: [Branch ~yade-pkg/yade/git-trunk] Rev 3840: Check, whether manipulatedFrame exist, if not - create it.

 

On 17/03/14 11:44, Anton Gladky wrote:
> 2014-03-17 9:23 GMT+01:00 Bruno Chareyre <bruno.chareyre@xxxxxxxxxxx>:
>> +       if(manipulatedFrame()==0) setManipulatedFrame(new qglviewer::ManipulatedFrame());
>>
>> It sounds like a memory leak. No?
> I believe no. It just checks,  whether manipulatedFrame exists and
> creates a new one, if it is not. Otherwise we get segfault on new
> QGLViewer.

IIRC, c++ textbooks teach us to always write a "delete" when we write a
"new".
In this case I don't see where this new manipulated frame would be deleted.
I can't imagine a big loss of memory unless someone repeatdly close/open
QGL view (and even in that case, not sure it would create a new frame
each time), but it is still a strange line.
It would be better to not manipulate when manipulatedFrame()==0, it
seems, since manipulating a standalone frame that is not displayed (the
"new" one) is always useless.

Bruno


References