[AD] Keeping non modified properties when grabbing

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Title: Keeping non modified properties when grabbing

The following patch changes the behavior of grabber when grabbing
an object on a slot which already has user properties. Any properties
that are not created by the grabbing process are not destroyed, as
they were before. I need this badly for my project, but other people
might be inconvenienced by this behavior, and I thought I'd submit it
for discussion. Feel free to apply or dismiss.
I'm just thinking this code could do with a command line switch to
select this behavior over the default one too. If this is the case,
you'll have to wait a bit, as I have very little time at the moment.


--- datedit.c.keep_props        Sat Aug 25 13:03:04 2001
+++ datedit.c   Sat Aug 25 13:13:15 2001
@@ -1538,6 +1538,16 @@
                                x, y, w, h, colordepth);
 
    if (tmp->dat) {
+      /* Do not discard user properties (the ones not already set in the
+         new object */
+      AL_CONST DATAFILE_PROPERTY *dp = dat->prop;
+      while (dp && (dp->type != DAT_END)) {
+         AL_CONST char *prop = get_datafile_property(tmp, dp->type);
+         if (!*prop) {
+            datedit_set_property(tmp, dp->type, dp->dat);
+         }
+         dp++;
+      }
       _unload_datafile_object(dat);
       *dat = *tmp;
       return TRUE;

--
Vincent Penquerc'h



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/