fix new_prop_string() when doing a name change on multiple selected instances

This commit is contained in:
stefan schippers 2023-10-04 00:44:43 +02:00
parent 5ffc7bb5e4
commit 9ecc5859b2
2 changed files with 4 additions and 0 deletions

View File

@ -1443,9 +1443,11 @@ static int update_symbol(const char *result, int x, int first_sel)
if(!pushed) { xctx->push_undo(); pushed=1;}
if(!k) hash_names(-1, XINSERT);
hash_names(*ii, XDELETE);
dbg(1, "update_symbol(): delete %s\n", xctx->inst[*ii].instname);
new_prop_string(*ii, ptr, k, /* sets also inst[].instname */
tclgetboolvar("disable_unique_names")); /* set new prop_ptr */
hash_names(*ii, XINSERT);
dbg(1, "update_symbol(): insert %s\n", xctx->inst[*ii].instname);
}
set_inst_flags(&xctx->inst[*ii]);
/* set cached flags in instances */

View File

@ -750,6 +750,7 @@ void new_prop_string(int i, const char *old_prop, int fast, int dis_uniq_names)
if(old_name==NULL) {
my_strdup(_ALLOC_ID_, &xctx->inst[i].prop_ptr, old_prop); /* changed to copy old props if no name */
my_strdup2(_ALLOC_ID_, &xctx->inst[i].instname, "");
return;
}
/* don't change old_prop if name does not conflict. */
@ -757,6 +758,7 @@ void new_prop_string(int i, const char *old_prop, int fast, int dis_uniq_names)
is_used = name_is_used(old_name, "", "", -1);
if(dis_uniq_names || is_used == -1 || is_used == i) {
my_strdup(_ALLOC_ID_, &xctx->inst[i].prop_ptr, old_prop);
my_strdup2(_ALLOC_ID_, &xctx->inst[i].instname, old_name);
my_free(_ALLOC_ID_, &old_name);
return;
}