From c8dc48f916c70dc40b26742badcbfb54cb6fb4ff Mon Sep 17 00:00:00 2001 From: Stefan Frederik Date: Mon, 30 Nov 2020 22:48:08 +0100 Subject: [PATCH] fix: load_wire() was using storeobject() for storing data, causing unwanted modify=1 flag (this has various side effects including changing window title) --- src/actions.c | 1 + src/save.c | 25 +++++++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/actions.c b/src/actions.c index b0ebc6ef..d926920e 100644 --- a/src/actions.c +++ b/src/actions.c @@ -34,6 +34,7 @@ void set_modify(int mod) { static int prev = -1; modified = mod; + dbg(1, "set_modify(): %d\n", mod); if(mod != prev) { prev = mod; if(has_x && strcmp(get_cell(xctx->sch[xctx->currsch],1), "systemlib/font")) { diff --git a/src/save.c b/src/save.c index 3553391c..32ec1817 100644 --- a/src/save.c +++ b/src/save.c @@ -495,19 +495,25 @@ static void load_text(FILE *fd) static void load_wire(FILE *fd) { + xWire *ptr; + int i; - double x1,y1,x2,y2; - char *ptr=NULL; + check_wire_storage(); + ptr = xctx->wire; + i = xctx->wires; dbg(3, "load_wire(): start\n"); - if(fscanf(fd, "%lf %lf %lf %lf",&x1, &y1, &x2, &y2 )<4) { + if(fscanf(fd, "%lf %lf %lf %lf",&ptr[i].x1, &ptr[i].y1, &ptr[i].x2, &ptr[i].y2 )<4) { fprintf(errfp,"WARNING: missing fields for WIRE object, ignoring\n"); read_line(fd, 0); - } else { - load_ascii_string( &ptr, fd); - ORDER(x1, y1, x2, y2); - storeobject(-1, x1,y1,x2,y2,WIRE,0,0,ptr); + return; } - my_free(883, &ptr); + ptr[i].prop_ptr = NULL; + ptr[i].end1 = ptr[i].end2 = ptr[i].bus = ptr[i].sel = 0; + load_ascii_string( &ptr[i].prop_ptr, fd); + ORDER(ptr[i].x1, ptr[i].y1, ptr[i].x2, ptr[i].y2); + if(!strcmp(get_tok_value(ptr[i].prop_ptr, "bus", 0), "true") ) ptr[i].bus = 1; + ptr[i].node = NULL; + xctx->wires++; } static void load_inst(int k, FILE *fd) @@ -701,8 +707,7 @@ static void load_line(FILE *fd) check_line_storage(c); i=xctx->lines[c]; ptr=xctx->line[c]; - if(fscanf(fd, "%lf %lf %lf %lf ",&ptr[i].x1, &ptr[i].y1, - &ptr[i].x2, &ptr[i].y2) < 4) { + if(fscanf(fd, "%lf %lf %lf %lf ",&ptr[i].x1, &ptr[i].y1, &ptr[i].x2, &ptr[i].y2) < 4) { fprintf(errfp,"WARNING: missing fields for LINE object, ignoring\n"); read_line(fd, 0); return;