Changeset 9d4dfdc for variable.c


Ignore:
Timestamp:
Jun 14, 2013, 7:39:23 PM (8 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master
Children:
41779bf, e428a36
Parents:
f20daff
git-author:
David Benjamin <davidben@mit.edu> (06/04/13 19:51:48)
git-committer:
David Benjamin <davidben@mit.edu> (06/14/13 19:39:23)
Message:
When replacing a variable, keep the old value

This unbreaks variable behavior on module reload.

Reported-By: Robert Jacobs <rnjacobs@mit.edu>
File:
1 edited

Legend:

Unmodified
Added
Removed
  • variable.c

    rf20daff r9d4dfdc  
    612612void owl_variable_dict_add_variable(owl_vardict * vardict,
    613613                                    owl_variable * var) {
     614  char *oldvalue = NULL;
     615  owl_variable *oldvar = owl_variable_get_var(vardict, var->name);
     616  /* Save the old value as a string. */
     617  if (oldvar) {
     618    oldvalue = owl_variable_get_tostring(oldvar);
     619  }
    614620  owl_dict_insert_element(vardict, var->name, var, (void (*)(void *))owl_variable_delete);
     621  /* Restore the old value. */
     622  if (oldvalue) {
     623    owl_variable_set_fromstring(var, oldvalue, 0);
     624    g_free(oldvalue);
     625  }
    615626}
    616627
Note: See TracChangeset for help on using the changeset viewer.