Hello,

Attached a patch that ensures that a new object is really created when
using CreateObjectTool. I actually encountered this because of another
problem with the DATADIR setting. I suppose the CreateObjectTool
rarely fails in normal environments.

Sameer.
-- 
http://www.it.iitb.ac.in/~sameerds/
=== modified file 'app/create_object.c'
--- app/create_object.c	2008-04-19 14:12:06 +0000
+++ app/create_object.c	2008-12-19 19:39:02 +0000
@@ -61,6 +61,7 @@
   obj = dia_object_default_create (tool->objtype, &clickedpoint,
                                    tool->user_data,
                                    &handle1, &handle2);
+  g_return_if_fail(obj);
 
   diagram_add_object(ddisp->diagram, obj);
 
@@ -125,9 +126,7 @@
 
   GList *parent_candidates;
 
-  g_return_if_fail (obj != NULL);
-  if (!obj) /* not sure if this isn't enough */
-    return; /* could be a legal invariant */
+  g_return_if_fail(obj);
 
   if (tool->moving) {
     gdk_pointer_ungrab (event->time);

=== modified file 'lib/object_defaults.c'
--- lib/object_defaults.c	2008-05-25 12:59:25 +0000
+++ lib/object_defaults.c	2008-12-19 19:39:02 +0000
@@ -268,26 +268,22 @@
 
   g_return_val_if_fail (type != NULL, NULL);
 
-  /* don't use dia_object_default_get() as it would insert the object into the hashtable (store defaults without being asked for it) */
+  /* don't use dia_object_default_get() as it would insert the object
+     into the hashtable (store defaults without being asked for it) */
   def_obj = g_hash_table_lookup (defaults_hash, type->name);
-  if (def_obj && def_obj->ops->describe_props)
-    {
-      /* copy properties to new object, but keep position */
-      obj = type->ops->create (startpoint, user_data, handle1, handle2);
-      if (obj)
-        {
-	  GPtrArray *props = prop_list_from_descs (
-	      object_get_prop_descriptions(def_obj), pdtpp_standard_or_defaults);
-          def_obj->ops->get_props(def_obj, props);
-          obj->ops->set_props(obj, props);
-	  obj->ops->move (obj, startpoint);
-          prop_list_free(props);
-	}
-    }
-  else
-    {
-      obj = type->ops->create (startpoint, user_data, handle1, handle2);
-    }
+
+  obj = type->ops->create (startpoint, user_data, handle1, handle2);
+  g_return_val_if_fail(obj, NULL);
+  
+  if (def_obj && def_obj->ops->describe_props) {
+    /* copy properties to new object, but keep position */
+    GPtrArray *props = prop_list_from_descs(object_get_prop_descriptions(def_obj),
+					    pdtpp_standard_or_defaults);
+    def_obj->ops->get_props(def_obj, props);
+    obj->ops->set_props(obj, props);
+    obj->ops->move (obj, startpoint);
+    prop_list_free(props);
+  }
 
   return obj;
 }

_______________________________________________
dia-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/dia-list
FAQ at http://live.gnome.org/Dia/Faq
Main page at http://live.gnome.org/Dia

Reply via email to