Corrected an obscure error that causes the background of the layout

window to change after hiding a layer using the toolbar and then
refreshing the layout.  Fixed by saving and restoring the graphics
state around the routine that configures the toolbar image.  Also
added a check to CifPaintCurrent to guard against using an unassigned
ClientData record as a pointer (causes a crash), and added braces
around "expr" values in the Tcl wrapper, which reportedly results in
faster execution of the expression.
This commit is contained in:
Tim Edwards 2018-10-23 08:44:04 -04:00
parent 08e0e9aab4
commit bb0af34441
3 changed files with 23 additions and 8 deletions

View File

@ -599,7 +599,13 @@ CIFPaintCurrent()
Plane **parray;
extern char *(cifReadLayers[MAXCIFRLAYERS]);
if (cifReadCellDef->cd_flags & CDFLATGDS)
/* NOTE: There should be no need to check for cd_client
* here as cd_client should not be CLIENTDEFAULT if CDFLATGDS
* is set in flags. This condition has occurred, though, and
* needs to be debugged.
*/
if ((cifReadCellDef->cd_flags & CDFLATGDS) &&
(cifReadCellDef->cd_client != (ClientData)CLIENTDEFAULT))
parray = (Plane **)cifReadCellDef->cd_client;
else
{

View File

@ -984,6 +984,8 @@ ImgLayerConfigureInstance(instancePtr)
Tk_Window tkwind = instancePtr->tkwin;
MagWindow *mw, tmpmw;
int saveStyle;
if (Tk_WindowId(tkwind) == 0)
Tk_MakeWindowExist(tkwind);
@ -1106,6 +1108,9 @@ ImgLayerConfigureInstance(instancePtr)
GrLock(&tmpmw, FALSE);
/* Save the current state */
saveStyle = grCurDStyle;
/* First fill with background style */
GrSetStuff(STYLE_ERASEALL);
grInformDriver();
@ -1156,9 +1161,13 @@ ImgLayerConfigureInstance(instancePtr)
grInformDriver();
GrDrawGlyphNum(masterPtr->layerLock, 0, 0);
}
/* Restore the original state */
GrSetStuff(saveStyle);
grInformDriver();
GrUnlock(&tmpmw);
}
return;
error:

View File

@ -553,8 +553,8 @@ proc magic::mgrupdate {win {cmdstr ""}} {
# Set default width and height to be 3/4 of the screen size.
set Opts(geometry) \
"[expr 3 * [winfo screenwidth .] / 4]x[expr 3 * [winfo screenheight .] \
/ 4]+100+100"
"[expr {3 * [winfo screenwidth .] / 4}]x[expr {3 * [winfo screenheight .] \
/ 4}]+100+100"
# Procedures for the layout scrollbars, which are made from canvas
# objects to avoid the problems associated with Tk's stupid scrollbar
@ -629,8 +629,8 @@ proc magic::cursorview {win} {
if {$cr == 0} {return}
set olst [${win} cursor internal]
set olstx [expr [lindex $olst 0]]
set olsty [expr [lindex $olst 1]]
set olstx [lindex $olst 0]
set olsty [lindex $olst 1]
if {$Opts(crosshair)} {
*bypass crosshair ${olstx}i ${olsty}i
@ -638,8 +638,8 @@ proc magic::cursorview {win} {
# Use catch, because occasionally this fails on startup
if {[catch {
set olstx [expr $olstx * $cr]
set olsty [expr $olsty * $cr]
set olstx [expr {$olstx * $cr}]
set olsty [expr {$olsty * $cr}]
}]} {return}
if {[${win} box exists]} {