dont access GC's Windows before checking them for being ExternalBytes instances
authorClaus Gittinger <cg@exept.de>
Mon, 11 Dec 1995 17:58:59 +0100
changeset 303 f2021d90f12d
parent 302 b12e58238233
child 304 1ec8278faf8a
dont access GC's Windows before checking them for being ExternalBytes instances
XWorkstat.st
XWorkstation.st
--- a/XWorkstat.st	Sun Dec 10 16:38:10 1995 +0100
+++ b/XWorkstat.st	Mon Dec 11 17:58:59 1995 +0100
@@ -12,14 +12,14 @@
 
 DeviceWorkstation subclass:#XWorkstation
 	 instanceVariableNames:'screen hasShapeExtension hasFaxExtension hasShmExtension
-                hasDPSExtension hasMbufExtension hasXVideoExtension hasSaveUnder
-                hasPEXExtension hasImageExtension hasInputExtension
-                ignoreBackingStore blackpixel whitepixel protocolsAtom
-                deleteWindowAtom saveYourselfAtom quitAppAtom primaryAtom
-                secondaryAtom cutBuffer0Atom stringAtom lengthAtom listOfXFonts
-                buttonsPressed eventRootX eventRootY displayName eventTrace
-                dispatchingExpose rgbVisual virtualRootId rootId eventBuffer
-                altModifierMask metaModifierMask'
+		hasDPSExtension hasMbufExtension hasXVideoExtension hasSaveUnder
+		hasPEXExtension hasImageExtension hasInputExtension
+		ignoreBackingStore blackpixel whitepixel protocolsAtom
+		deleteWindowAtom saveYourselfAtom quitAppAtom primaryAtom
+		secondaryAtom cutBuffer0Atom stringAtom lengthAtom listOfXFonts
+		buttonsPressed eventRootX eventRootY displayName eventTrace
+		dispatchingExpose rgbVisual virtualRootId rootId eventBuffer
+		altModifierMask metaModifierMask'
 	 classVariableNames:'RawKeysymTranslation'
 	 poolDictionaries:''
 	 category:'Interface-Graphics'
@@ -2296,7 +2296,7 @@
 
 %{  /* NOCONTEXT */
 #ifdef FAX
-    GC gc = _GCVal(aGCId);
+    GC gc;
     FAXImage source;
     Drawable dest;
 
@@ -2307,6 +2307,7 @@
      && __bothSmallInteger(w, h)
      && __bothSmallInteger(srcX, srcY)
      && __bothSmallInteger(dstX, dstY)) {
+	gc = _GCVal(aGCId);
 	source = (FAXImage) _WindowVal(sourceId);
 	dest = (Drawable) _WindowVal(destId);
 	XFAXImageCopyImage(myDpy, source, dest, gc,
@@ -2330,7 +2331,7 @@
 
 %{  /* NOCONTEXT */
 
-    GC gc = _GCVal(aGCId);
+    GC gc;
     Drawable source, dest;
 
     if (__isExternalAddress(aGCId)
@@ -2339,6 +2340,7 @@
      && __bothSmallInteger(w, h)
      && __bothSmallInteger(srcX, srcY)
      && __bothSmallInteger(dstX, dstY)) {
+	gc = _GCVal(aGCId);
 	source = (Drawable) _WindowVal(sourceId);
 	dest = (Drawable) _WindowVal(destId);
 	XCopyArea(myDpy, source, dest, gc,
@@ -2364,7 +2366,7 @@
 
 %{  /* NOCONTEXT */
 
-    GC gc = _GCVal(aGCId);
+    GC gc;
     Drawable source, dest;
 
     if (__isExternalAddress(aGCId)
@@ -2373,6 +2375,7 @@
      && __bothSmallInteger(w, h)
      && __bothSmallInteger(srcX, srcY)
      && __bothSmallInteger(dstX, dstY)) {
+	gc = _GCVal(aGCId);
 	source = (Drawable) _WindowVal(sourceId);
 	dest = (Drawable) _WindowVal(destId);
 	XCopyPlane(myDpy, source, dest, gc,
@@ -2394,8 +2397,8 @@
 
 %{  /* NOCONTEXT */
 
-    GC gc = _GCVal(aGCId);
-    Window win = _WindowVal(aDrawableId);
+    GC gc;
+    Window win;
     int w, h, angle1, angle2;
     double f;
 
@@ -2415,6 +2418,8 @@
      && __isExternalAddress(aDrawableId)
      && __bothSmallInteger(x, y)
      && __bothSmallInteger(width, height)) {
+	win = _WindowVal(aDrawableId);
+	gc = _GCVal(aGCId);
 	w = _intVal(width);
 	h = _intVal(height);
 	/*
@@ -2436,13 +2441,15 @@
 
 %{  /* NOCONTEXT */
 
-    GC gc = _GCVal(aGCId);
-    Window win = _WindowVal(aDrawableId);
+    GC gc;
+    Window win;
 
     if (__isExternalAddress(aGCId)
      && __isExternalAddress(aDrawableId)
      && __bothSmallInteger(x0, y0)
      && __bothSmallInteger(x1, y1)) {
+	gc = _GCVal(aGCId);
+	win = _WindowVal(aDrawableId);
 	XDrawLine(myDpy, win, gc, _intVal(x0), _intVal(y0),
 				  _intVal(x1), _intVal(y1));
 	RETURN ( self );
@@ -2457,12 +2464,14 @@
 
 %{  /* NOCONTEXT */
 
-    GC gc = _GCVal(aGCId);
-    Window win = _WindowVal(aDrawableId);
+    GC gc;
+    Window win;
 
     if (__isExternalAddress(aGCId)
      && __isExternalAddress(aDrawableId)
      && __bothSmallInteger(x, y)) {
+	gc = _GCVal(aGCId);
+	win = _WindowVal(aDrawableId);
 	XDrawPoint(myDpy, win, gc, _intVal(x), _intVal(y));
 	RETURN ( self );
     }
@@ -2480,8 +2489,8 @@
 
     numberOfPoints := aPolygon size.
 %{
-    GC gc = _GCVal(aGCId);
-    Window win = _WindowVal(aDrawableId);
+    GC gc;
+    Window win;
     extern OBJ Point, __AT_();
     OBJ point, x, y;
     int i, num;
@@ -2491,6 +2500,8 @@
     if (__isExternalAddress(aGCId)
      && __isExternalAddress(aDrawableId)
      && __isSmallInteger(numberOfPoints)) {
+	gc = _GCVal(aGCId);
+	win = _WindowVal(aDrawableId);
 	num = _intVal(numberOfPoints);
 	/*
 	 * avoid a (slow) malloc, if the number of points is small
@@ -2527,14 +2538,16 @@
 
 %{  /* NOCONTEXT */
 
-    GC gc = _GCVal(aGCId);
-    Window win = _WindowVal(aDrawableId);
+    GC gc;
+    Window win;
     int w, h;
 
     if (__isExternalAddress(aGCId)
      && __isExternalAddress(aDrawableId)
      && __bothSmallInteger(x, y)
      && __bothSmallInteger(width, height)) {
+	gc = _GCVal(aGCId);
+	win = _WindowVal(aDrawableId);
 	w = _intVal(width);
 	h = _intVal(height);
 	/*
@@ -2557,8 +2570,8 @@
 
 %{  /* NOCONTEXT */
 
-    GC gc = _GCVal(aGCId);
-    Window win = _WindowVal(aDrawableId);
+    GC gc;
+    Window win;
     unsigned char *cp;
     OBJ cls;
     int  i1, i2, l, n;
@@ -2568,6 +2581,8 @@
      && __isNonNilObject(aString)
      && __bothSmallInteger(index1, index2)
      && __bothSmallInteger(x, y)) {
+	gc = _GCVal(aGCId);
+	win = _WindowVal(aDrawableId);
 	cls = __qClass(aString);
 	if ((cls == String) || (cls == Symbol)) {
 	    i1 = _intVal(index1) - 1;
@@ -2620,8 +2635,8 @@
 
 %{  /* NOCONTEXT */
 
-    GC gc = _GCVal(aGCId);
-    Window win = _WindowVal(aDrawableId);
+    GC gc;
+    Window win;
     unsigned char *cp;
     int n;
     OBJ cls;
@@ -2630,6 +2645,8 @@
      && __isExternalAddress(aDrawableId)
      && __isNonNilObject(aString)
      && __bothSmallInteger(x, y)) {
+	gc = _GCVal(aGCId);
+	win = _WindowVal(aDrawableId);
 	cls = __qClass(aString);
 	if ((cls == String) || (cls == Symbol)) {
 	    cp = _stringVal(aString);
@@ -2729,8 +2746,8 @@
 
 %{  /* NOCONTEXT */
 
-    GC gc = _GCVal(aGCId);
-    Window win = _WindowVal(aDrawableId);
+    GC gc;
+    Window win;
     int w, h, angle1, angle2;
     double f;
 
@@ -2750,6 +2767,8 @@
      && __isExternalAddress(aDrawableId)
      && __bothSmallInteger(x, y)
      && __bothSmallInteger(width, height)) {
+	gc = _GCVal(aGCId);
+	win = _WindowVal(aDrawableId);
 	w = _intVal(width);
 	h = _intVal(height);
 	/*
@@ -2774,8 +2793,8 @@
 
     numberOfPoints := aPolygon size.
 %{
-    GC gc = _GCVal(aGCId);
-    Window win = _WindowVal(aDrawableId);
+    GC gc;
+    Window win;
     OBJ point, x, y;
     extern OBJ Point, __AT_();
     int i, num;
@@ -2785,6 +2804,8 @@
     if (__isExternalAddress(aGCId)
      && __isExternalAddress(aDrawableId)
      && __isSmallInteger(numberOfPoints)) {
+	gc = _GCVal(aGCId);
+	win = _WindowVal(aDrawableId);
 	num = _intVal(numberOfPoints);
 	if (num < 3) {
 	    RETURN ( self );
@@ -2864,8 +2885,8 @@
      * XPutImage
      */
     Display *dpy = myDpy;
-    GC gc = _GCVal(aGCId);
-    Window win = _WindowVal(aDrawableId);
+    GC gc;
+    Window win;
     XImage image;
 
     if (__isExternalAddress(aGCId)
@@ -2876,6 +2897,8 @@
      && __bothSmallInteger(imageWidth, imageHeight)
      && __bothSmallInteger(imageDepth, bitsPerPixel)
      && __isByteArray(imageBits)) {
+	gc = _GCVal(aGCId);
+	win = _WindowVal(aDrawableId);
 #ifdef ARGDEBUG
 	printf("args ok\n");
 #endif
@@ -4719,9 +4742,10 @@
 %{  /* NOCONTEXT */
 
     XGCValues gcv;
-    GC gc = _GCVal(aGCId);
+    GC gc;
 
     if (__isExternalAddress(aGCId)) {
+	gc = _GCVal(aGCId);
 	gcv.clip_mask = None;
 	XChangeGC(myDpy, gc, GCClipMask, &gcv);
 	RETURN ( self );
@@ -4750,10 +4774,11 @@
 %{  /* NOCONTEXT */
 
     Display *dpy = myDpy;
-    GC gc = _GCVal(aGCId);
+    GC gc;
     Pixmap bitmap;
 
     if (__isExternalAddress(aGCId)) {
+	gc = _GCVal(aGCId);
 	if (__isExternalAddress(aBitmapId)) {
 	    bitmap = _PixmapVal(aBitmapId);
 	    XSetStipple(dpy, gc, bitmap);
@@ -4775,9 +4800,10 @@
 %{  /* NOCONTEXT */
 
     XGCValues gcv;
-    GC gc = _GCVal(aGCId);
+    GC gc;
 
     if (__isExternalAddress(aGCId)) {
+	gc = _GCVal(aGCId);
 	if (aBool == true)
 	    gcv.subwindow_mode = ClipByChildren;
 	else
@@ -4837,10 +4863,12 @@
 %{  /* NOCONTEXT */
 
     Display *dpy = myDpy;
-    GC gc = _GCVal(aGCId);
+    GC gc;
 
     if (__bothSmallInteger(fgColorIndex, bgColorIndex)
      && __isExternalAddress(aGCId)) {
+	gc = _GCVal(aGCId);
+
 	XSetForeground(dpy, gc, _intVal(fgColorIndex));
 	XSetBackground(dpy, gc, _intVal(bgColorIndex));
 	RETURN ( self );
@@ -4856,9 +4884,10 @@
 %{  /* NOCONTEXT */
 
     Display *dpy = myDpy;
-    GC gc = _GCVal(aGCId);
+    GC gc;
 
     if (__isExternalAddress(aGCId)) {
+	gc = _GCVal(aGCId);
 	if (__isSmallInteger(fgColor))
 	    XSetForeground(dpy, gc, _intVal(fgColor));
 	if (__isSmallInteger(bgColor))
@@ -4885,9 +4914,10 @@
 %{  /* NOCONTEXT */
 
     Display *dpy = myDpy;
-    GC gc = _GCVal(aGCId);
+    GC gc;
 
     if (__isExternalAddress(aGCId)) {
+	gc = _GCVal(aGCId);
 	if (__isSmallInteger(lw)) {
 	    XSetLineAttributes(dpy, gc, _intVal(lw),
 				    LineSolid, CapNotLast, JoinMiter);
@@ -4930,10 +4960,11 @@
 
 %{  /* NOCONTEXT */
 
-    GC gc = _GCVal(aGCId);
+    GC gc;
     int fun = -1;
 
     if (__isExternalAddress(aGCId)) {
+	gc = _GCVal(aGCId);
 	if (aFunctionSymbol == @symbol(copy)) fun = GXcopy;
 	else if (aFunctionSymbol == @symbol(copyInverted)) fun = GXcopyInverted;
 	else if (aFunctionSymbol == @symbol(xor)) fun = GXxor;
@@ -5031,10 +5062,11 @@
 %{  /* NOCONTEXT */
 
     Display *dpy = myDpy;
-    GC gc = _GCVal(aGCId);
+    GC gc;
     Pixmap pixmap;
 
     if (__isExternalAddress(aGCId)) {
+	gc = _GCVal(aGCId);
 	if (__isExternalAddress(aPixmapId)) {
 	    pixmap = _PixmapVal(aPixmapId);
 	    XSetTile(dpy, gc, pixmap);
@@ -5789,12 +5821,13 @@
 
 %{  /* UNLIMITEDSTACK NOCONTEXT */
 
-    Window win = _WindowVal(aDrawableId);
+    Window win;
     XImage *img;
     int ret;
     int xpos, ypos;
 
     if (__isExternalAddress(aDrawableId) && __bothSmallInteger(x, y)) {
+	win = _WindowVal(aDrawableId);
 	xpos = _intVal(x);
 	ypos = _intVal(y);
 	if ((xpos < 0) || (ypos < 0)) {
@@ -5816,7 +5849,7 @@
 %{  /* UNLIMITEDSTACK */
 
     Display *dpy = myDpy;
-    Window win = _WindowVal(aDrawableId);
+    Window win;
     XImage *image = (XImage *)0;
     int pad, bytes_per_line, numBytes;
 
@@ -5825,6 +5858,7 @@
      && __bothSmallInteger(w, h)
      && __isArray(info)
      && __isByteArray(imageBits)) {
+	win = _WindowVal(aDrawableId);
 	image = XGetImage(dpy, win, _intVal(srcx), _intVal(srcy),
 				    _intVal(w), _intVal(h),
 				    (unsigned)AllPlanes, ZPixmap);
@@ -6988,6 +7022,6 @@
 !XWorkstation class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Attic/XWorkstat.st,v 1.88 1995-12-10 00:21:44 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Attic/XWorkstat.st,v 1.89 1995-12-11 16:58:59 cg Exp $'
 ! !
 XWorkstation initialize!
--- a/XWorkstation.st	Sun Dec 10 16:38:10 1995 +0100
+++ b/XWorkstation.st	Mon Dec 11 17:58:59 1995 +0100
@@ -12,14 +12,14 @@
 
 DeviceWorkstation subclass:#XWorkstation
 	 instanceVariableNames:'screen hasShapeExtension hasFaxExtension hasShmExtension
-                hasDPSExtension hasMbufExtension hasXVideoExtension hasSaveUnder
-                hasPEXExtension hasImageExtension hasInputExtension
-                ignoreBackingStore blackpixel whitepixel protocolsAtom
-                deleteWindowAtom saveYourselfAtom quitAppAtom primaryAtom
-                secondaryAtom cutBuffer0Atom stringAtom lengthAtom listOfXFonts
-                buttonsPressed eventRootX eventRootY displayName eventTrace
-                dispatchingExpose rgbVisual virtualRootId rootId eventBuffer
-                altModifierMask metaModifierMask'
+		hasDPSExtension hasMbufExtension hasXVideoExtension hasSaveUnder
+		hasPEXExtension hasImageExtension hasInputExtension
+		ignoreBackingStore blackpixel whitepixel protocolsAtom
+		deleteWindowAtom saveYourselfAtom quitAppAtom primaryAtom
+		secondaryAtom cutBuffer0Atom stringAtom lengthAtom listOfXFonts
+		buttonsPressed eventRootX eventRootY displayName eventTrace
+		dispatchingExpose rgbVisual virtualRootId rootId eventBuffer
+		altModifierMask metaModifierMask'
 	 classVariableNames:'RawKeysymTranslation'
 	 poolDictionaries:''
 	 category:'Interface-Graphics'
@@ -2296,7 +2296,7 @@
 
 %{  /* NOCONTEXT */
 #ifdef FAX
-    GC gc = _GCVal(aGCId);
+    GC gc;
     FAXImage source;
     Drawable dest;
 
@@ -2307,6 +2307,7 @@
      && __bothSmallInteger(w, h)
      && __bothSmallInteger(srcX, srcY)
      && __bothSmallInteger(dstX, dstY)) {
+	gc = _GCVal(aGCId);
 	source = (FAXImage) _WindowVal(sourceId);
 	dest = (Drawable) _WindowVal(destId);
 	XFAXImageCopyImage(myDpy, source, dest, gc,
@@ -2330,7 +2331,7 @@
 
 %{  /* NOCONTEXT */
 
-    GC gc = _GCVal(aGCId);
+    GC gc;
     Drawable source, dest;
 
     if (__isExternalAddress(aGCId)
@@ -2339,6 +2340,7 @@
      && __bothSmallInteger(w, h)
      && __bothSmallInteger(srcX, srcY)
      && __bothSmallInteger(dstX, dstY)) {
+	gc = _GCVal(aGCId);
 	source = (Drawable) _WindowVal(sourceId);
 	dest = (Drawable) _WindowVal(destId);
 	XCopyArea(myDpy, source, dest, gc,
@@ -2364,7 +2366,7 @@
 
 %{  /* NOCONTEXT */
 
-    GC gc = _GCVal(aGCId);
+    GC gc;
     Drawable source, dest;
 
     if (__isExternalAddress(aGCId)
@@ -2373,6 +2375,7 @@
      && __bothSmallInteger(w, h)
      && __bothSmallInteger(srcX, srcY)
      && __bothSmallInteger(dstX, dstY)) {
+	gc = _GCVal(aGCId);
 	source = (Drawable) _WindowVal(sourceId);
 	dest = (Drawable) _WindowVal(destId);
 	XCopyPlane(myDpy, source, dest, gc,
@@ -2394,8 +2397,8 @@
 
 %{  /* NOCONTEXT */
 
-    GC gc = _GCVal(aGCId);
-    Window win = _WindowVal(aDrawableId);
+    GC gc;
+    Window win;
     int w, h, angle1, angle2;
     double f;
 
@@ -2415,6 +2418,8 @@
      && __isExternalAddress(aDrawableId)
      && __bothSmallInteger(x, y)
      && __bothSmallInteger(width, height)) {
+	win = _WindowVal(aDrawableId);
+	gc = _GCVal(aGCId);
 	w = _intVal(width);
 	h = _intVal(height);
 	/*
@@ -2436,13 +2441,15 @@
 
 %{  /* NOCONTEXT */
 
-    GC gc = _GCVal(aGCId);
-    Window win = _WindowVal(aDrawableId);
+    GC gc;
+    Window win;
 
     if (__isExternalAddress(aGCId)
      && __isExternalAddress(aDrawableId)
      && __bothSmallInteger(x0, y0)
      && __bothSmallInteger(x1, y1)) {
+	gc = _GCVal(aGCId);
+	win = _WindowVal(aDrawableId);
 	XDrawLine(myDpy, win, gc, _intVal(x0), _intVal(y0),
 				  _intVal(x1), _intVal(y1));
 	RETURN ( self );
@@ -2457,12 +2464,14 @@
 
 %{  /* NOCONTEXT */
 
-    GC gc = _GCVal(aGCId);
-    Window win = _WindowVal(aDrawableId);
+    GC gc;
+    Window win;
 
     if (__isExternalAddress(aGCId)
      && __isExternalAddress(aDrawableId)
      && __bothSmallInteger(x, y)) {
+	gc = _GCVal(aGCId);
+	win = _WindowVal(aDrawableId);
 	XDrawPoint(myDpy, win, gc, _intVal(x), _intVal(y));
 	RETURN ( self );
     }
@@ -2480,8 +2489,8 @@
 
     numberOfPoints := aPolygon size.
 %{
-    GC gc = _GCVal(aGCId);
-    Window win = _WindowVal(aDrawableId);
+    GC gc;
+    Window win;
     extern OBJ Point, __AT_();
     OBJ point, x, y;
     int i, num;
@@ -2491,6 +2500,8 @@
     if (__isExternalAddress(aGCId)
      && __isExternalAddress(aDrawableId)
      && __isSmallInteger(numberOfPoints)) {
+	gc = _GCVal(aGCId);
+	win = _WindowVal(aDrawableId);
 	num = _intVal(numberOfPoints);
 	/*
 	 * avoid a (slow) malloc, if the number of points is small
@@ -2527,14 +2538,16 @@
 
 %{  /* NOCONTEXT */
 
-    GC gc = _GCVal(aGCId);
-    Window win = _WindowVal(aDrawableId);
+    GC gc;
+    Window win;
     int w, h;
 
     if (__isExternalAddress(aGCId)
      && __isExternalAddress(aDrawableId)
      && __bothSmallInteger(x, y)
      && __bothSmallInteger(width, height)) {
+	gc = _GCVal(aGCId);
+	win = _WindowVal(aDrawableId);
 	w = _intVal(width);
 	h = _intVal(height);
 	/*
@@ -2557,8 +2570,8 @@
 
 %{  /* NOCONTEXT */
 
-    GC gc = _GCVal(aGCId);
-    Window win = _WindowVal(aDrawableId);
+    GC gc;
+    Window win;
     unsigned char *cp;
     OBJ cls;
     int  i1, i2, l, n;
@@ -2568,6 +2581,8 @@
      && __isNonNilObject(aString)
      && __bothSmallInteger(index1, index2)
      && __bothSmallInteger(x, y)) {
+	gc = _GCVal(aGCId);
+	win = _WindowVal(aDrawableId);
 	cls = __qClass(aString);
 	if ((cls == String) || (cls == Symbol)) {
 	    i1 = _intVal(index1) - 1;
@@ -2620,8 +2635,8 @@
 
 %{  /* NOCONTEXT */
 
-    GC gc = _GCVal(aGCId);
-    Window win = _WindowVal(aDrawableId);
+    GC gc;
+    Window win;
     unsigned char *cp;
     int n;
     OBJ cls;
@@ -2630,6 +2645,8 @@
      && __isExternalAddress(aDrawableId)
      && __isNonNilObject(aString)
      && __bothSmallInteger(x, y)) {
+	gc = _GCVal(aGCId);
+	win = _WindowVal(aDrawableId);
 	cls = __qClass(aString);
 	if ((cls == String) || (cls == Symbol)) {
 	    cp = _stringVal(aString);
@@ -2729,8 +2746,8 @@
 
 %{  /* NOCONTEXT */
 
-    GC gc = _GCVal(aGCId);
-    Window win = _WindowVal(aDrawableId);
+    GC gc;
+    Window win;
     int w, h, angle1, angle2;
     double f;
 
@@ -2750,6 +2767,8 @@
      && __isExternalAddress(aDrawableId)
      && __bothSmallInteger(x, y)
      && __bothSmallInteger(width, height)) {
+	gc = _GCVal(aGCId);
+	win = _WindowVal(aDrawableId);
 	w = _intVal(width);
 	h = _intVal(height);
 	/*
@@ -2774,8 +2793,8 @@
 
     numberOfPoints := aPolygon size.
 %{
-    GC gc = _GCVal(aGCId);
-    Window win = _WindowVal(aDrawableId);
+    GC gc;
+    Window win;
     OBJ point, x, y;
     extern OBJ Point, __AT_();
     int i, num;
@@ -2785,6 +2804,8 @@
     if (__isExternalAddress(aGCId)
      && __isExternalAddress(aDrawableId)
      && __isSmallInteger(numberOfPoints)) {
+	gc = _GCVal(aGCId);
+	win = _WindowVal(aDrawableId);
 	num = _intVal(numberOfPoints);
 	if (num < 3) {
 	    RETURN ( self );
@@ -2864,8 +2885,8 @@
      * XPutImage
      */
     Display *dpy = myDpy;
-    GC gc = _GCVal(aGCId);
-    Window win = _WindowVal(aDrawableId);
+    GC gc;
+    Window win;
     XImage image;
 
     if (__isExternalAddress(aGCId)
@@ -2876,6 +2897,8 @@
      && __bothSmallInteger(imageWidth, imageHeight)
      && __bothSmallInteger(imageDepth, bitsPerPixel)
      && __isByteArray(imageBits)) {
+	gc = _GCVal(aGCId);
+	win = _WindowVal(aDrawableId);
 #ifdef ARGDEBUG
 	printf("args ok\n");
 #endif
@@ -4719,9 +4742,10 @@
 %{  /* NOCONTEXT */
 
     XGCValues gcv;
-    GC gc = _GCVal(aGCId);
+    GC gc;
 
     if (__isExternalAddress(aGCId)) {
+	gc = _GCVal(aGCId);
 	gcv.clip_mask = None;
 	XChangeGC(myDpy, gc, GCClipMask, &gcv);
 	RETURN ( self );
@@ -4750,10 +4774,11 @@
 %{  /* NOCONTEXT */
 
     Display *dpy = myDpy;
-    GC gc = _GCVal(aGCId);
+    GC gc;
     Pixmap bitmap;
 
     if (__isExternalAddress(aGCId)) {
+	gc = _GCVal(aGCId);
 	if (__isExternalAddress(aBitmapId)) {
 	    bitmap = _PixmapVal(aBitmapId);
 	    XSetStipple(dpy, gc, bitmap);
@@ -4775,9 +4800,10 @@
 %{  /* NOCONTEXT */
 
     XGCValues gcv;
-    GC gc = _GCVal(aGCId);
+    GC gc;
 
     if (__isExternalAddress(aGCId)) {
+	gc = _GCVal(aGCId);
 	if (aBool == true)
 	    gcv.subwindow_mode = ClipByChildren;
 	else
@@ -4837,10 +4863,12 @@
 %{  /* NOCONTEXT */
 
     Display *dpy = myDpy;
-    GC gc = _GCVal(aGCId);
+    GC gc;
 
     if (__bothSmallInteger(fgColorIndex, bgColorIndex)
      && __isExternalAddress(aGCId)) {
+	gc = _GCVal(aGCId);
+
 	XSetForeground(dpy, gc, _intVal(fgColorIndex));
 	XSetBackground(dpy, gc, _intVal(bgColorIndex));
 	RETURN ( self );
@@ -4856,9 +4884,10 @@
 %{  /* NOCONTEXT */
 
     Display *dpy = myDpy;
-    GC gc = _GCVal(aGCId);
+    GC gc;
 
     if (__isExternalAddress(aGCId)) {
+	gc = _GCVal(aGCId);
 	if (__isSmallInteger(fgColor))
 	    XSetForeground(dpy, gc, _intVal(fgColor));
 	if (__isSmallInteger(bgColor))
@@ -4885,9 +4914,10 @@
 %{  /* NOCONTEXT */
 
     Display *dpy = myDpy;
-    GC gc = _GCVal(aGCId);
+    GC gc;
 
     if (__isExternalAddress(aGCId)) {
+	gc = _GCVal(aGCId);
 	if (__isSmallInteger(lw)) {
 	    XSetLineAttributes(dpy, gc, _intVal(lw),
 				    LineSolid, CapNotLast, JoinMiter);
@@ -4930,10 +4960,11 @@
 
 %{  /* NOCONTEXT */
 
-    GC gc = _GCVal(aGCId);
+    GC gc;
     int fun = -1;
 
     if (__isExternalAddress(aGCId)) {
+	gc = _GCVal(aGCId);
 	if (aFunctionSymbol == @symbol(copy)) fun = GXcopy;
 	else if (aFunctionSymbol == @symbol(copyInverted)) fun = GXcopyInverted;
 	else if (aFunctionSymbol == @symbol(xor)) fun = GXxor;
@@ -5031,10 +5062,11 @@
 %{  /* NOCONTEXT */
 
     Display *dpy = myDpy;
-    GC gc = _GCVal(aGCId);
+    GC gc;
     Pixmap pixmap;
 
     if (__isExternalAddress(aGCId)) {
+	gc = _GCVal(aGCId);
 	if (__isExternalAddress(aPixmapId)) {
 	    pixmap = _PixmapVal(aPixmapId);
 	    XSetTile(dpy, gc, pixmap);
@@ -5789,12 +5821,13 @@
 
 %{  /* UNLIMITEDSTACK NOCONTEXT */
 
-    Window win = _WindowVal(aDrawableId);
+    Window win;
     XImage *img;
     int ret;
     int xpos, ypos;
 
     if (__isExternalAddress(aDrawableId) && __bothSmallInteger(x, y)) {
+	win = _WindowVal(aDrawableId);
 	xpos = _intVal(x);
 	ypos = _intVal(y);
 	if ((xpos < 0) || (ypos < 0)) {
@@ -5816,7 +5849,7 @@
 %{  /* UNLIMITEDSTACK */
 
     Display *dpy = myDpy;
-    Window win = _WindowVal(aDrawableId);
+    Window win;
     XImage *image = (XImage *)0;
     int pad, bytes_per_line, numBytes;
 
@@ -5825,6 +5858,7 @@
      && __bothSmallInteger(w, h)
      && __isArray(info)
      && __isByteArray(imageBits)) {
+	win = _WindowVal(aDrawableId);
 	image = XGetImage(dpy, win, _intVal(srcx), _intVal(srcy),
 				    _intVal(w), _intVal(h),
 				    (unsigned)AllPlanes, ZPixmap);
@@ -6988,6 +7022,6 @@
 !XWorkstation class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.88 1995-12-10 00:21:44 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.89 1995-12-11 16:58:59 cg Exp $'
 ! !
 XWorkstation initialize!