Prevent a crash when saving a PasteCanvas with no canvas specified.
authordooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Thu, 30 Aug 2007 22:40:40 +0000 (22:40 +0000)
committerdooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Thu, 30 Aug 2007 22:40:40 +0000 (22:40 +0000)
git-svn-id: http://svn.voria.com/code@565 1f10aa63-cdf2-0310-b900-c93c546f37ac

synfig-core/trunk/src/synfig/savecanvas.cpp

index 5bfd6ec..6129f71 100644 (file)
@@ -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 <No Image
+                               // Selected> 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());