From 82910603b0e4d9c0fe57e826977e1f63eb12c3f7 Mon Sep 17 00:00:00 2001 From: hobbs Date: Wed, 22 Dec 1999 20:01:07 +0000 Subject: * generic/tkScale.c: * generic/tkScale.h: * mac/tkMacScale.c: * unix/tkUnixScale.c: fixed potential segv from patch in 3897 --- generic/tkScale.c | 7 ++++--- generic/tkScale.h | 16 +++++++++------- mac/tkMacScale.c | 16 +++++++--------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/generic/tkScale.c b/generic/tkScale.c index ee942e9..cb1fdce 100644 --- a/generic/tkScale.c +++ b/generic/tkScale.c @@ -18,7 +18,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkScale.c,v 1.9 1999/12/21 23:55:11 hobbs Exp $ + * RCS: @(#) $Id: tkScale.c,v 1.10 1999/12/22 20:01:07 hobbs Exp $ */ #include "tkPort.h" @@ -1084,6 +1084,7 @@ ScaleCmdDeletedProc(clientData) */ if (!(scalePtr->flags & SCALE_DELETED)) { + scalePtr->flags |= SCALE_DELETED; Tk_DestroyWindow(tkwin); } } @@ -1114,11 +1115,11 @@ TkEventuallyRedrawScale(scalePtr, what) * or REDRAW_ALL. */ { if ((what == 0) || (scalePtr->tkwin == NULL) - || (scalePtr->flags & SCALE_DELETED) || !Tk_IsMapped(scalePtr->tkwin)) { return; } - if ((scalePtr->flags & REDRAW_ALL) == 0) { + if (!(scalePtr->flags & REDRAW_PENDING)) { + scalePtr->flags |= REDRAW_PENDING; Tcl_DoWhenIdle(TkpDisplayScale, (ClientData) scalePtr); } scalePtr->flags |= what; diff --git a/generic/tkScale.h b/generic/tkScale.h index 2a5daf5..7d78dc5 100644 --- a/generic/tkScale.h +++ b/generic/tkScale.h @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkScale.h,v 1.6 1999/12/21 23:55:11 hobbs Exp $ + * RCS: @(#) $Id: tkScale.h,v 1.7 1999/12/22 20:01:08 hobbs Exp $ */ #ifndef _TKSCALE @@ -174,6 +174,7 @@ typedef struct TkScale { * REDRAW_OTHER - 1 means other stuff besides slider and value * need to be redrawn. * REDRAW_ALL - 1 means the entire widget needs to be redrawn. + * REDRAW_PENDING - 1 means any sort of redraw is pending * ACTIVE - 1 means the widget is active (the mouse is * in its window). * INVOKE_COMMAND - 1 means the scale's command needs to be @@ -195,12 +196,13 @@ typedef struct TkScale { #define REDRAW_SLIDER (1<<0) #define REDRAW_OTHER (1<<1) #define REDRAW_ALL (REDRAW_OTHER|REDRAW_SLIDER) -#define ACTIVE (1<<2) -#define INVOKE_COMMAND (1<<3) -#define SETTING_VAR (1<<4) -#define NEVER_SET (1<<5) -#define GOT_FOCUS (1<<6) -#define SCALE_DELETED (1<<7) +#define REDRAW_PENDING (1<<2) +#define ACTIVE (1<<3) +#define INVOKE_COMMAND (1<<4) +#define SETTING_VAR (1<<5) +#define NEVER_SET (1<<6) +#define GOT_FOCUS (1<<7) +#define SCALE_DELETED (1<<8) /* * Symbolic values for the active parts of a slider. These are diff --git a/mac/tkMacScale.c b/mac/tkMacScale.c index f3f6fd8..c189e37 100644 --- a/mac/tkMacScale.c +++ b/mac/tkMacScale.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacScale.c,v 1.3 1999/05/22 06:35:05 jingham Exp $ + * RCS: @(#) $Id: tkMacScale.c,v 1.4 1999/12/22 20:01:10 hobbs Exp $ */ #include "tkScale.h" @@ -146,7 +146,8 @@ TkpDisplayScale(clientData) CGrafPtr saveWorld; GDHandle saveDevice; MacDrawable *macDraw; - + + scalePtr->flags &= ~REDRAW_PENDING; if ((scalePtr->tkwin == NULL) || !Tk_IsMapped(scalePtr->tkwin)) { goto done; } @@ -168,7 +169,7 @@ TkpDisplayScale(clientData) Tcl_Release((ClientData) interp); } scalePtr->flags &= ~INVOKE_COMMAND; - if (scalePtr->tkwin == NULL) { + if (scalePtr->flags & SCALE_DELETED) { Tcl_Release((ClientData) scalePtr); return; } @@ -183,12 +184,9 @@ TkpDisplayScale(clientData) if (scalePtr->highlightWidth != 0) { GC gc; - if (scalePtr->flags & GOT_FOCUS) { - gc = Tk_GCForColor(scalePtr->highlightColorPtr, Tk_WindowId(tkwin)); - } else { - gc = Tk_GCForColor(scalePtr->highlightColorPtr, Tk_WindowId(tkwin)); - } - Tk_DrawFocusHighlight(tkwin, gc, scalePtr->highlightWidth, Tk_WindowId(tkwin)); + gc = Tk_GCForColor(scalePtr->highlightColorPtr, Tk_WindowId(tkwin)); + Tk_DrawFocusHighlight(tkwin, gc, scalePtr->highlightWidth, + Tk_WindowId(tkwin)); } Tk_Draw3DRectangle(tkwin, Tk_WindowId(tkwin), scalePtr->bgBorder, scalePtr->highlightWidth, scalePtr->highlightWidth, -- cgit v0.12