redundant code elimination in new_schematic(), fixed a memory leak in update_symbol()

This commit is contained in:
Stefan Frederik 2021-11-03 00:31:08 +01:00
parent 6dbd952910
commit 3ec3add6c0
5 changed files with 1745 additions and 1764 deletions

File diff suppressed because it is too large Load Diff

View File

@ -5072,6 +5072,9 @@
<Component Id="cmp502DE4191401E3D01123A0FFEDC0F658" Guid="{26D4E444-5A42-489D-9A03-C1218F6E5263}">
<File Id="fil58FEE426321DD1EFEF26924163F7C545" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\xschem_simulator\dev-1.sym" />
</Component>
<Component Id="cmpB728F7329A645D789CCDADA012106747" Guid="{5646B955-BD2C-4A24-8956-8F2D9FFF28C8}">
<File Id="filA5ED31D6C4AB4C299BFCE9A6DABB7AA1" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\xschem_simulator\dev-2.sym" />
</Component>
<Component Id="cmpCD0B1BE956EEA7AAF6C2D301A41ED2D6" Guid="{E01FE85D-1348-4998-8968-D07C5F49BE97}">
<File Id="fil295761403E113FB646EAA4F421734E22" KeyPath="yes" Source="$(var.xschemLibrarySrcDir)\xschem_simulator\dfrbp_1.sym" />
</Component>
@ -6903,6 +6906,7 @@
<ComponentRef Id="cmpDFA5C50E5F33CA73144A3B548B782FFB" />
<ComponentRef Id="cmp5BFBD053346A12A4CB8146D3A1CB8F46" />
<ComponentRef Id="cmp502DE4191401E3D01123A0FFEDC0F658" />
<ComponentRef Id="cmpB728F7329A645D789CCDADA012106747" />
<ComponentRef Id="cmpCD0B1BE956EEA7AAF6C2D301A41ED2D6" />
<ComponentRef Id="cmp8F85892CF93EE49EAEDC65C6E55BD6AA" />
<ComponentRef Id="cmpBCB98C1A0EF900FCB9DFC06BC74E63EF" />

View File

@ -921,6 +921,7 @@ void update_symbol(const char *result, int x)
i=xctx->sel_array[0].n;
if(!result) {
dbg(1, "update_symbol(): edit symbol prop aborted\n");
my_free(1289, &old_prop);
return;
}
/* create new_prop updated attribute string */
@ -1235,9 +1236,9 @@ void edit_property(int x)
symbol_bbox(j, &xctx->inst[j].x1, &xctx->inst[j].y1,
&xctx->inst[j].x2, &xctx->inst[j].y2);
}
} /* end for(j */
} /* end for(j...) */
return;
}
} /* if((xctx->lastsel==0 ) */
switch(xctx->sel_array[0].type)
{

View File

@ -823,7 +823,6 @@ void preview_window(const char *what, const char *tk_win_path, const char *filen
#define MAX_NEW_WINDOWS 20
void new_schematic(const char *what, const char *tk_win_path, const char *filename)
{
static int initialized = 0;
static int cnt = 0;
static Xschem_ctx *save_xctx[MAX_NEW_WINDOWS]; /* save pointer to current schematic context structure */
static Tk_Window tknew_window[MAX_NEW_WINDOWS];
@ -840,10 +839,6 @@ void new_schematic(const char *what, const char *tk_win_path, const char *filena
}
save_xctx[0] = xctx; /* save current schematic */
tknew_window[0] = Tk_NameToWindow(interp, ".drw", mainwindow);
if(!initialized) {
tcleval("bind .drw <Enter> {+ new_window switch .drw}");
initialized = 1;
}
}
if(cnt + 1 >= MAX_NEW_WINDOWS) return; /* no more free slots */
cnt++;
@ -853,7 +848,6 @@ void new_schematic(const char *what, const char *tk_win_path, const char *filena
break;
}
}
tknew_window[n] = Tk_NameToWindow(interp, tk_win_path, mainwindow);
Tk_MakeWindowExist(tknew_window[n]);
new_window = Tk_WindowId(tknew_window[n]);
@ -866,24 +860,6 @@ void new_schematic(const char *what, const char *tk_win_path, const char *filena
resetwin(1, 0, 1, 0, 0); /* create preview pixmap. resetwin(create_pixmap, clear_pixmap, force, w, h) */
load_schematic(1,filename, 0);
zoom_full(1, 0, 1, 0.97); /* draw */
} else if(!strcmp(what, "redraw")) {
Xschem_ctx *save;
if(cnt) {
save = xctx;
tkwin = Tk_NameToWindow(interp, tk_win_path, mainwindow);
for(i = 0; i < MAX_NEW_WINDOWS; i++) {
if(tkwin == tknew_window[i]) {
n = i;
break;
}
}
if(n >= 0 && n < MAX_NEW_WINDOWS) {
xctx = save_xctx[n];
draw();
xctx = save;
set_modify(xctx->modified); /* restore modified status */
}
}
} else if(!strcmp(what, "destroy")) {
if(cnt) {
dbg(1, "new_schematic() destroy\n");

View File

@ -3315,17 +3315,11 @@ proc new_window {what {path {}} {filename {}}} {
update
xschem new_schematic create $path $filename
set_bindings $path
bind $path <Expose> "new_window redraw $path"
wm protocol $path WM_DELETE_WINDOW "new_window destroy $path"
bind $path <Enter> "new_window switch $path"
wm protocol $path WM_DELETE_WINDOW "xschem new_schematic destroy $path {}"
} elseif { $what eq {destroy_all}} {
xschem new_schematic destroy_all {} {}
} elseif { $what eq {destroy}} {
xschem new_schematic destroy $path {}
} elseif { $what eq {switch}} {
xschem new_schematic switch $path {}
} elseif { $what eq {redraw}} {
xschem new_schematic redraw $path {}
}
}
@ -3355,7 +3349,8 @@ global env has_x
bind $window_path <Double-Button-1> {xschem callback -3 %x %y 0 %b 0 %s}
bind $window_path <Double-Button-2> {xschem callback -3 %x %y 0 %b 0 %s}
bind $window_path <Double-Button-3> {xschem callback -3 %x %y 0 %b 0 %s}
bind $window_path <Expose> {xschem callback %T %x %y 0 %w %h %s}
bind $window_path <Expose> "xschem new_schematic switch $window_path {}
xschem callback %T %x %y 0 %w %h %s"
bind $window_path <Configure> {xschem windowid; xschem callback %T %x %y 0 %w %h 0}
bind $window_path <ButtonPress> {
xschem callback %T %x %y 0 %b 0 %s
@ -3381,7 +3376,8 @@ global env has_x
}
bind $window_path <KeyRelease> {xschem callback %T %x %y %N 0 0 %s} ;# 20161118
bind $window_path <Motion> {xschem callback %T %x %y 0 0 0 %s}
bind $window_path <Enter> {xschem callback %T %x %y 0 0 0 0 }
bind $window_path <Enter> "xschem new_schematic switch $window_path {}
xschem callback %T %x %y 0 0 0 0"
bind $window_path <Leave> {}
bind $window_path <Unmap> {
wm withdraw .infotext