From 1cc17a4ac143e337dc4bb2b1d9514a085bced7af Mon Sep 17 00:00:00 2001 From: dooglus Date: Thu, 30 Aug 2007 22:40:40 +0000 Subject: [PATCH] Prevent a crash when saving a PasteCanvas with no canvas specified. git-svn-id: http://svn.voria.com/code@565 1f10aa63-cdf2-0310-b900-c93c546f37ac --- synfig-core/trunk/src/synfig/savecanvas.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/synfig-core/trunk/src/synfig/savecanvas.cpp b/synfig-core/trunk/src/synfig/savecanvas.cpp index 5bfd6ec..6129f71 100644 --- a/synfig-core/trunk/src/synfig/savecanvas.cpp +++ b/synfig-core/trunk/src/synfig/savecanvas.cpp @@ -583,16 +583,25 @@ xmlpp::Element* encode_layer(xmlpp::Element* root,Layer::ConstHandle layer) continue; } - if(value.get_type()==ValueBase::TYPE_CANVAS && !value.get(Canvas::LooseHandle())->is_inline()) + if(value.get_type()==ValueBase::TYPE_CANVAS) { - Canvas::Handle child(value.get(Canvas::LooseHandle())); + // the ->is_inline() below was crashing if the canvas + // contained a PasteCanvas with the default Canvas setting; this avoids the crash + if (!value.get(Canvas::LooseHandle())) + continue; + + if (!value.get(Canvas::LooseHandle())->is_inline()) + { + Canvas::Handle child(value.get(Canvas::LooseHandle())); - if(!value.get(Canvas::Handle())) + if(!value.get(Canvas::Handle())) + continue; + xmlpp::Element *node=root->add_child("param"); + node->set_attribute("name",iter->get_name()); + node->set_attribute("use",child->get_relative_id(layer->get_canvas())); continue; - xmlpp::Element *node=root->add_child("param"); - node->set_attribute("name",iter->get_name()); - node->set_attribute("use",child->get_relative_id(layer->get_canvas())); - continue; + } } xmlpp::Element *node=root->add_child("param"); node->set_attribute("name",iter->get_name()); -- 2.7.4