diff options
author | hobbs <hobbs> | 2004-12-02 02:10:37 (GMT) |
---|---|---|
committer | hobbs <hobbs> | 2004-12-02 02:10:37 (GMT) |
commit | faf27421f44ec721bbcaa5836e21297f1fa57832 (patch) | |
tree | 569cde081bd6b95759a394075519d813986c41a4 | |
parent | 3051ba20af89c12c489e91c71d04df0bb8afb7ac (diff) | |
download | tk-faf27421f44ec721bbcaa5836e21297f1fa57832.zip tk-faf27421f44ec721bbcaa5836e21297f1fa57832.tar.gz tk-faf27421f44ec721bbcaa5836e21297f1fa57832.tar.bz2 |
* unix/tkUnixButton.c (TkpDisplayButton): constrain coords to
Tk_RedrawImage to display only portion that is valid.
* generic/tkImgPhoto.c (ImgPhotoDisplay): add X error suppression
around XGetImage to prevent app abort. [Bug 979239]
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | generic/tkImgPhoto.c | 11 | ||||
-rw-r--r-- | unix/tkUnixButton.c | 54 |
3 files changed, 69 insertions, 4 deletions
@@ -1,4 +1,12 @@ +2004-12-01 Jeff Hobbs <jeffh@ActiveState.com> + + * unix/tkUnixButton.c (TkpDisplayButton): constrain coords to + Tk_RedrawImage to display only portion that is valid. + * generic/tkImgPhoto.c (ImgPhotoDisplay): add X error suppression + around XGetImage to prevent app abort. [Bug 979239] + 2004-11-28 Joe English <jenglish@users.sourceforge.net> + * unix/tkUnixRFont.c(Tk_DrawChars): Check for short integer overflow in x,y coordinates [Fixes: #942320 "Tk, Xft, text and long lines"] diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c index 46ae9d4..76a07dd 100644 --- a/generic/tkImgPhoto.c +++ b/generic/tkImgPhoto.c @@ -17,7 +17,7 @@ * Department of Computer Science, * Australian National University. * - * RCS: @(#) $Id: tkImgPhoto.c,v 1.51 2004/10/26 14:07:57 patthoyts Exp $ + * RCS: @(#) $Id: tkImgPhoto.c,v 1.52 2004/12/02 02:10:37 hobbs Exp $ */ #include "tkInt.h" @@ -2784,14 +2784,22 @@ ImgPhotoDisplay(clientData, display, drawable, imageX, imageY, width, if ((instancePtr->masterPtr->flags & COMPLEX_ALPHA) && visInfo.depth >= 15 && (visInfo.class == DirectColor || visInfo.class == TrueColor)) { + Tk_ErrorHandler handler; XImage *bgImg = NULL; /* + * Create an error handler to suppress the case where the input was + * not properly constrained, which can cause an X error. [Bug 979239] + */ + handler = Tk_CreateErrorHandler(display, -1, -1, -1, + (Tk_ErrorProc *) NULL, (ClientData) NULL); + /* * Pull the current background from the display to blend with */ bgImg = XGetImage(display, drawable, drawableX, drawableY, (unsigned int)width, (unsigned int)height, AllPlanes, ZPixmap); if (bgImg == NULL) { + Tk_DeleteErrorHandler(handler); return; } @@ -2806,6 +2814,7 @@ ImgPhotoDisplay(clientData, display, drawable, imageX, imageY, width, bgImg, 0, 0, drawableX, drawableY, (unsigned int) width, (unsigned int) height); XDestroyImage(bgImg); + Tk_DeleteErrorHandler(handler); } else { /* * masterPtr->region describes which parts of the image contain diff --git a/unix/tkUnixButton.c b/unix/tkUnixButton.c index 526f70b..cc29a1c 100644 --- a/unix/tkUnixButton.c +++ b/unix/tkUnixButton.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: tkUnixButton.c,v 1.19 2004/05/04 00:39:51 hobbs Exp $ + * RCS: @(#) $Id: tkUnixButton.c,v 1.20 2004/12/02 02:10:38 hobbs Exp $ */ #include "tkButton.h" @@ -505,12 +505,12 @@ TkpDisplayButton(clientData) } case COMPOUND_NONE: {break;} } - + TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, butPtr->padY, butPtr->indicatorSpace + fullWidth, fullHeight, &x, &y); x += butPtr->indicatorSpace; - + x += offset; y += offset; if (relief == TK_RELIEF_RAISED) { @@ -525,6 +525,30 @@ TkpDisplayButton(clientData) imageYOffset += y; if (butPtr->image != NULL) { + /* + * Do boundary clipping, so that Tk_RedrawImage is passed + * valid coordinates. [Bug 979239] + */ + + if (imageXOffset < 0) { + imageXOffset = 0; + } + if (imageYOffset < 0) { + imageYOffset = 0; + } + if (width > Tk_Width(tkwin)) { + width = Tk_Width(tkwin); + } + if (height > Tk_Height(tkwin)) { + height = Tk_Height(tkwin); + } + if ((width + imageXOffset) > Tk_Width(tkwin)) { + imageXOffset = Tk_Width(tkwin) - width; + } + if ((height + imageYOffset) > Tk_Height(tkwin)) { + imageYOffset = Tk_Height(tkwin) - height; + } + if ((butPtr->selectImage != NULL) && (butPtr->flags & SELECTED)) { Tk_RedrawImage(butPtr->selectImage, 0, 0, width, height, pixmap, imageXOffset, imageYOffset); @@ -567,6 +591,30 @@ TkpDisplayButton(clientData) imageXOffset += x; imageYOffset += y; if (butPtr->image != NULL) { + /* + * Do boundary clipping, so that Tk_RedrawImage is passed + * valid coordinates. [Bug 979239] + */ + + if (imageXOffset < 0) { + imageXOffset = 0; + } + if (imageYOffset < 0) { + imageYOffset = 0; + } + if (width > Tk_Width(tkwin)) { + width = Tk_Width(tkwin); + } + if (height > Tk_Height(tkwin)) { + height = Tk_Height(tkwin); + } + if ((width + imageXOffset) > Tk_Width(tkwin)) { + imageXOffset = Tk_Width(tkwin) - width; + } + if ((height + imageYOffset) > Tk_Height(tkwin)) { + imageYOffset = Tk_Height(tkwin) - height; + } + if ((butPtr->selectImage != NULL) && (butPtr->flags & SELECTED)) { Tk_RedrawImage(butPtr->selectImage, 0, 0, width, |