summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordas <das>2008-02-27 00:12:50 (GMT)
committerdas <das>2008-02-27 00:12:50 (GMT)
commit272d56b4d4d87fc6632e541053a413515fc4821c (patch)
treeb268bdf707ff430c2192b4226e40b6a35337f026
parent29f91ab2655696f677e223d4900ce0aee97968a9 (diff)
downloadtk-272d56b4d4d87fc6632e541053a413515fc4821c.zip
tk-272d56b4d4d87fc6632e541053a413515fc4821c.tar.gz
tk-272d56b4d4d87fc6632e541053a413515fc4821c.tar.bz2
* macosx/tkMacOSXDraw.c: workaround leak in Carbon SetPortPenPixPat()
API [Bug 1863346]; avoid repeated PixPat allocation/deallocation.
-rw-r--r--ChangeLog5
-rw-r--r--macosx/tkMacOSXDraw.c38
2 files changed, 31 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 37456c5..75e9327 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-02-27 Daniel Steffen <das@users.sourceforge.net>
+
+ * macosx/tkMacOSXDraw.c: workaround leak in Carbon SetPortPenPixPat()
+ API [Bug 1863346]; avoid repeated PixPat allocation/deallocation.
+
2008-02-06 Don Porter <dgp@users.sourceforge.net>
*** 8.4.18 TAGGED FOR RELEASE ***
diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c
index 5d1157c..f0b83be 100644
--- a/macosx/tkMacOSXDraw.c
+++ b/macosx/tkMacOSXDraw.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXDraw.c,v 1.2.2.30 2007/11/09 06:26:55 das Exp $
+ * RCS: @(#) $Id: tkMacOSXDraw.c,v 1.2.2.31 2008/02/27 00:12:59 das Exp $
*/
#include "tkMacOSXPrivate.h"
@@ -45,7 +45,7 @@ int tkMacOSXUseCGDrawing = 1;
int tkPictureIsOpen;
-static PixPatHandle penPat = NULL;
+static PixPatHandle penPat = NULL, tmpPixPat = NULL;
static int cgAntiAliasLimit = 0;
#define notAA(w) ((w) < cgAntiAliasLimit)
@@ -1504,20 +1504,27 @@ TkMacOSXSetUpGraphicsPort(
GC gc, /* GC to apply to current port. */
GWorldPtr destPort)
{
+ CGrafPtr savePort;
+ Boolean portChanged;
+
+ portChanged = QDSwapPort(destPort, &savePort);
PenNormal();
if (gc) {
- if (penPat == NULL) {
- penPat = NewPixPat();
+ if (!penPat) {
+ if (!tmpPixPat) {
+ penPat = NewPixPat();
+ } else {
+ penPat = tmpPixPat;
+ tmpPixPat = NULL;
+ }
}
TkMacOSXSetColorInPort(gc->foreground, 1, penPat, destPort);
- SetPortPenPixPat(destPort, penPat);
+ PenPixPat(penPat);
if(gc->function == GXxor) {
- SetPortPenMode(destPort, patXor);
+ PenMode(patXor);
}
if (gc->line_width > 1) {
- Point s = {gc->line_width, gc->line_width};
-
- SetPortPenSize(destPort, s);
+ PenSize(gc->line_width, gc->line_width);
}
if (gc->line_style != LineSolid) {
/*
@@ -1526,6 +1533,9 @@ TkMacOSXSetUpGraphicsPort(
*/
}
}
+ if (portChanged) {
+ QDSwapPort(savePort, NULL);
+ }
}
/*
@@ -1578,7 +1588,7 @@ TkMacOSXSetupDrawingContext(
goto end;
}
if (useCG) {
- dc.context = macDraw->context;;
+ dc.context = macDraw->context;
}
if (!dc.context || !(macDraw->flags & TK_IS_PIXMAP)) {
dc.port = TkMacOSXGetDrawablePort(d);
@@ -1745,7 +1755,11 @@ TkMacOSXRestoreDrawingContext(
DisposeRgn(dcPtr->saveClip);
}
if (dcPtr->penPat) {
- DisposePixPat(dcPtr->penPat);
+ if (!tmpPixPat) {
+ tmpPixPat = dcPtr->penPat;
+ } else {
+ DisposePixPat(dcPtr->penPat);
+ }
}
if (dcPtr->saveState) {
ChkErr(SetThemeDrawingState, dcPtr->saveState, true);
@@ -1758,7 +1772,7 @@ TkMacOSXRestoreDrawingContext(
QDSwapPort(dcPtr->savePort, NULL);
}
#ifdef TK_MAC_DEBUG
- bzero(dcPtr, sizeof(dcPtr));
+ bzero(dcPtr, sizeof(TkMacOSXDrawingContext));
#endif /* TK_MAC_DEBUG */
}