X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fsynfig%2Fcanvas.cpp;h=c50b901e73e2656ecb3d6b2a878bd9adda34194e;hb=756c0d29ac1742f231e6615f9a577e574e35a4af;hp=c51507a0607fe11505b72b3b832cbe58cca3841d;hpb=bec46bc8d42dab13851b47714c1095d8c8f9f9c3;p=synfig.git diff --git a/synfig-core/trunk/src/synfig/canvas.cpp b/synfig-core/trunk/src/synfig/canvas.cpp index c51507a..c50b901 100644 --- a/synfig-core/trunk/src/synfig/canvas.cpp +++ b/synfig-core/trunk/src/synfig/canvas.cpp @@ -6,7 +6,7 @@ ** ** \legal ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley -** Copyright (c) 2007 Chris Moore +** Copyright (c) 2007, 2008 Chris Moore ** ** This package is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License as @@ -94,9 +94,16 @@ Canvas::~Canvas() // refering to a canvas after it had been destroyed; this code // will stop the pastecanvas layers from refering to the canvas // before the canvas is destroyed - for (std::set::iterator iter = parent_set.begin(); iter != parent_set.end(); iter++) + + // the set_sub_canvas(0) ends up deleting the parent-child link, + // which deletes the current element from the set we're iterating + // through, so we have to make sure we've incremented the iterator + // before we mess with the pastecanvas + std::set::iterator iter = parent_set.begin(); + while (iter != parent_set.end()) { Layer_PasteCanvas* paste_canvas = dynamic_cast(*iter); + iter++; if(paste_canvas) paste_canvas->set_sub_canvas(0); else