Prevent a crash when clicking in the workarea after adding a PasteCanvas but not...
authordooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Thu, 30 Aug 2007 22:43:22 +0000 (22:43 +0000)
committerdooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Thu, 30 Aug 2007 22:43:22 +0000 (22:43 +0000)
git-svn-id: http://svn.voria.com/code@566 1f10aa63-cdf2-0310-b900-c93c546f37ac

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

index d76318f..a769b33 100644 (file)
@@ -244,18 +244,19 @@ Layer_PasteCanvas::hit_check(synfig::Context context, const synfig::Point &pos)c
 {
        if(depth==MAX_DEPTH)return 0;depth_counter counter(depth);
 
-       Point target_pos=(pos-canvas->rend_desc().get_focus()-origin)/exp(zoom)+canvas->rend_desc().get_focus();
+       if (canvas) {
+               Point target_pos=(pos-canvas->rend_desc().get_focus()-origin)/exp(zoom)+canvas->rend_desc().get_focus();
 
-       if(canvas && get_amount() && canvas->get_context().get_color(target_pos).get_a()>=0.25)
-       {
-               if(!children_lock)
+               if(canvas && get_amount() && canvas->get_context().get_color(target_pos).get_a()>=0.25)
                {
-                       return canvas->get_context().hit_check(target_pos);
+                       if(!children_lock)
+                       {
+                               return canvas->get_context().hit_check(target_pos);
+                       }
+                       return const_cast<Layer_PasteCanvas*>(this);
                }
-               return const_cast<Layer_PasteCanvas*>(this);
        }
-       else
-               return context.hit_check(pos);
+       return context.hit_check(pos);
 }
 
 Color