X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fcontainer.cpp;h=e125672eac63c6690d4d1cbc4da044e08a9e6ee7;hb=9d5d4488ba75c407709556a7ed56b8d16e21834e;hp=8a9c07bcc297a64193d7b8c98ee0b27e2de874c3;hpb=b8c3c411826c1df00e54daeaf6cd820685f4f460;p=architektonas diff --git a/src/container.cpp b/src/container.cpp index 8a9c07b..e125672 100644 --- a/src/container.cpp +++ b/src/container.cpp @@ -4,11 +4,13 @@ // (C) 2011 Underground Software // See the README and GPLv3 files for licensing and warranty information // -// JLH = James L. Hammons +// JLH = James Hammons // // WHO WHEN WHAT // --- ---------- ------------------------------------------------------------ // JLH 03/30/2011 Created this file +// JLH 06/02/2011 Added code to delete objects in this container when they go +// out of scope // #include "container.h" @@ -23,9 +25,15 @@ Container::Container(Vector p1, Object * p/*= NULL*/): Object(p1, p), Container::~Container() { + // No memory leaks! + while (objects.size() > 0) + { + delete objects[0]; + objects.erase(objects.begin()); + } } -/*virtual*/ void Container::Draw(QPainter * painter) +/*virtual*/ void Container::Draw(Painter * painter) { for(int i=0; i<(int)objects.size(); i++) objects[i]->Draw(painter);