summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonal.k.fellows@manchester.ac.uk <dkf>2009-09-09 22:23:57 (GMT)
committerdonal.k.fellows@manchester.ac.uk <dkf>2009-09-09 22:23:57 (GMT)
commit3c97bee1b85a80feef1a01c7ef42abcd833392b8 (patch)
tree8eaf41ae141685c48f89c4741ca2877212ff1e19
parentd328e9bc52096134bc4f315332c189c90802293b (diff)
downloadtk-3c97bee1b85a80feef1a01c7ef42abcd833392b8.zip
tk-3c97bee1b85a80feef1a01c7ef42abcd833392b8.tar.gz
tk-3c97bee1b85a80feef1a01c7ef42abcd833392b8.tar.bz2
Try to make Tk more resilient in the face of Xft allocation failures.
-rw-r--r--ChangeLog13
-rw-r--r--generic/tkFont.c10
-rw-r--r--unix/tkUnixRFont.c16
3 files changed, 36 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 1f0e326..1c29e02 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2009-09-09 Donal K. Fellows <dkf@users.sf.net>
+
+ * unix/tkUnixRFont.c (InitFont): Move pattern disposal in error case
+ to callers so they have more options when they come to recovering from
+ the failure.
+ (TkpGetFontFromAttributes): If the default attributes don't work, try
+ adding a setting to turn off use of XRender. That seems to work for
+ some people for unexplained reasons (possibly local misconfiguration).
+ * generic/tkFont.c (Tk_AllocFontFromObj): Stop this function from
+ keeling over in a heap when the low-level font allocation fails. An
+ error beats a crash! (Issue reported on comp.lang.tcl by Denis
+ Berezhnoy.)
+
2009-09-07 Daniel Steffen <das@users.sourceforge.net>
* generic/tkFocus.c: fix potential null dereference flagged by clang
diff --git a/generic/tkFont.c b/generic/tkFont.c
index cfb6d80..27303a0 100644
--- a/generic/tkFont.c
+++ b/generic/tkFont.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkFont.c,v 1.56 2009/07/21 15:16:47 dkf Exp $
+ * RCS: @(#) $Id: tkFont.c,v 1.57 2009/09/09 22:23:58 dkf Exp $
*/
#include "tkInt.h"
@@ -1188,6 +1188,14 @@ Tk_AllocFontFromObj(
*/
fontPtr = TkpGetFontFromAttributes(NULL, tkwin, &fa);
+ if (fontPtr == NULL) {
+ Tcl_AppendResult(interp, "failed to allocate font due to ",
+ "internal font engine problem", NULL);
+ if (isNew) {
+ Tcl_DeleteHashEntry(cacheHashPtr);
+ }
+ return NULL;
+ }
}
}
diff --git a/unix/tkUnixRFont.c b/unix/tkUnixRFont.c
index 00b8095..e11015f 100644
--- a/unix/tkUnixRFont.c
+++ b/unix/tkUnixRFont.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkUnixRFont.c,v 1.27 2008/11/22 18:08:51 dkf Exp $
+ * RCS: @(#) $Id: tkUnixRFont.c,v 1.28 2009/09/09 22:23:58 dkf Exp $
*/
#include "tkUnixInt.h"
@@ -244,7 +244,6 @@ InitFont(
set = FcFontSort(0, pattern, FcTrue, NULL, &result);
if (!set) {
- FcPatternDestroy(pattern);
ckfree((char *) fontPtr);
return NULL;
}
@@ -353,6 +352,7 @@ TkpGetNativeFont(
fontPtr = InitFont(tkwin, pattern, NULL);
if (!fontPtr) {
+ FcPatternDestroy(pattern);
return NULL;
}
return &fontPtr->font;
@@ -418,7 +418,19 @@ TkpGetFontFromAttributes(
FinishedWithFont(fontPtr);
}
fontPtr = InitFont(tkwin, pattern, fontPtr);
+
+ /*
+ * Hack to work around issues with weird issues with Xft/Xrender
+ * connection.
+ */
+
if (!fontPtr) {
+ XftPatternAddBool(pattern, XFT_RENDER, FcFalse);
+ fontPtr = InitFont(tkwin, pattern, fontPtr);
+ }
+
+ if (!fontPtr) {
+ FcPatternDestroy(pattern);
return NULL;
}
return &fontPtr->font;