summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordas <das>2008-02-27 00:12:32 (GMT)
committerdas <das>2008-02-27 00:12:32 (GMT)
commit7d088554d32905ccf1b8f98e9082d7d0d49830a8 (patch)
tree71510bf0cb6d538646615e81a600d9c0b2e21663
parent6654ca14fff1fe29caf02e626fb790df3104bd91 (diff)
downloadtk-7d088554d32905ccf1b8f98e9082d7d0d49830a8.zip
tk-7d088554d32905ccf1b8f98e9082d7d0d49830a8.tar.gz
tk-7d088554d32905ccf1b8f98e9082d7d0d49830a8.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 734888a..ec64826 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-23 Joe English <jenglish@users.sourceforge.net>
* library/ttk/combobox.tcl, doc/ttk_combobox.n,
diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c
index d8001f1..c1fe8c5 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.32 2007/12/13 15:27:09 dgp Exp $
+ * RCS: @(#) $Id: tkMacOSXDraw.c,v 1.33 2008/02/27 00:12:33 das Exp $
*/
#include "tkMacOSXPrivate.h"
@@ -43,7 +43,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)
@@ -1502,20 +1502,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) {
/*
@@ -1524,6 +1531,9 @@ TkMacOSXSetUpGraphicsPort(
*/
}
}
+ if (portChanged) {
+ QDSwapPort(savePort, NULL);
+ }
}
/*
@@ -1576,7 +1586,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);
@@ -1743,7 +1753,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);
@@ -1756,7 +1770,7 @@ TkMacOSXRestoreDrawingContext(
QDSwapPort(dcPtr->savePort, NULL);
}
#ifdef TK_MAC_DEBUG
- bzero(dcPtr, sizeof(dcPtr));
+ bzero(dcPtr, sizeof(TkMacOSXDrawingContext));
#endif /* TK_MAC_DEBUG */
}