On 4/29/07, Lars Clausen <[EMAIL PROTECTED]> wrote:
On Tue, 2007-04-24 at 10:29 +0530, Sameer Sahasrabuddhe wrote:
>
> Also, do_set_props_from_offsets() searches for a matching offset for
> each property that it tries to set. It ignores if no offset is found.
> Should we introduce an assertion instead? It might not work if there
> is code that tries to set a property without really checking if it is
> defined. We could a throw a warning in that case, but that could
> result in a lot of clutter on stderr.
Definitely not an assertion, that's way too brutal. A warning may be a
good idea, and then a round of fixing the current ones.
I think I have a mid-way solution that should do the trick. I have
modified the above function, so that it asserts that the type is same
for a property and its offset, if the name matches. This implies that
across all objects in a diagram, if two objects declare a property
with the same name, then the type should also be the same.
Attaching a patch. Please comment! I think this is a good thing for
general peace of mind when changing property types.
Sameer.
--
Research Scholar, KReSIT, IIT Bombay
http://www.it.iitb.ac.in/~sameerds/
Index: lib/propoffsets.c
===================================================================
--- lib/propoffsets.c (revision 3697)
+++ lib/propoffsets.c (working copy)
@@ -39,13 +39,21 @@
Property *prop = g_ptr_array_index(props,i);
const PropOffset *ofs;
for (ofs = offsets; ofs->name ; ofs++) {
- if ((prop->name_quark == ofs->name_quark) &&
- (prop->type_quark == ofs->type_quark)) {
+ /* Two props cannot have the same name but different types. */
+ if (prop->name_quark == ofs->name_quark) {
+ if (prop->type_quark != ofs->type_quark) {
+ g_printerr("Property name: %s\n", prop->name);
+ g_printerr("Property type: %s\n", prop->type);
+ g_printerr("Offset type: %s\n", ofs->type);
+ g_assert(FALSE &&
+ "Property type mismatch when setting from offsets");
+ }
+
/* beware of props not set, see PROP_FLAG_OPTIONAL */
if ((prop->experience & PXP_NOTSET) == 0)
prop->ops->set_from_offset(prop,base,ofs->offset,ofs->offset2);
break;
- }
+ }
}
}
}
_______________________________________________
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