[teklib-general] teklib: X11 Display: Fixed some memory leaks and initialization ...

Timm S. Mueller tmueller at neoscientists.org
Mon Jul 13 10:13:51 CEST 2009


details:   http://hg.teklib.org/teklib/rev/4eab5b6033cc
changeset: 265:4eab5b6033cc
user:      Timm S. Mueller <tmueller at neoscientists.org>
date:      Sun Jun 14 15:06:18 2009 +0200
description:
X11 Display: Fixed some memory leaks and initialization problems, improved
some global symbol names, improved Xft closedown procedure, fixed problems in
stdin line reader and build problems in newer Linux distributions

diffs (truncated from 423 to 100 lines):

diff -r 7256b8f1b5f9 -r 4eab5b6033cc src/display_x11/display_x11_all.c
--- a/src/display_x11/display_x11_all.c	Thu May 07 14:49:07 2009 +0200
+++ b/src/display_x11/display_x11_all.c	Sun Jun 14 15:06:18 2009 +0200
@@ -19,6 +19,9 @@
 #endif
 
 #include "../teklib/teklib.c"
+#if defined(TDEBUG) && TDEBUG > 0
+#include "../teklib/debug.c"
+#endif
 
 #include "display_x11_mod.c"
 #include "display_x11_api.c"
diff -r 7256b8f1b5f9 -r 4eab5b6033cc src/display_x11/display_x11_api.c
--- a/src/display_x11/display_x11_api.c	Thu May 07 14:49:07 2009 +0200
+++ b/src/display_x11/display_x11_api.c	Sun Jun 14 15:06:18 2009 +0200
@@ -15,6 +15,7 @@
 	TAPTR TExecBase = TGetExecBase(mod);
 	TTAGITEM *tags = req->tvr_Op.OpenWindow.Tags;
 	X11WINDOW *v = TAlloc0(mod->x11_MemMgr, sizeof(X11WINDOW));
+	XTextProperty title_prop;
 
 	req->tvr_Op.OpenWindow.Window = v;
 	if (v == TNULL) return;
@@ -157,9 +158,14 @@
 		if (v->sizehints->flags)
 			XSetWMNormalHints(mod->x11_Display, v->window, v->sizehints);
 
-		XStringListToTextProperty((char **) &v->title, 1, &v->title_prop);
-		XSetWMProperties(mod->x11_Display, v->window, &v->title_prop,
-			NULL, NULL, 0, NULL, NULL, NULL);
+		if (Xutf8TextListToTextProperty(mod->x11_Display, 
+			(char **) &v->title, 1, XUTF8StringStyle, &title_prop) ==
+			Success)
+		{
+			XSetWMProperties(mod->x11_Display, v->window, &title_prop,
+				NULL, NULL, 0, NULL, NULL, NULL);
+			XFree(title_prop.value);
+		}
 
 		v->atom_wm_delete_win = XInternAtom(mod->x11_Display,
 			"WM_DELETE_WINDOW", True);
@@ -918,12 +924,12 @@
 **	additionally have to enclose XShmAttach() in a mutex.
 */
 
-static TBOOL shm_available = TTRUE;
+static TBOOL x11_shm_available = TTRUE;
 
 static int shm_errhandler(Display *d, XErrorEvent *evt)
 {
 	TDBPRINTF(TDB_ERROR,("Remote display - fallback to normal XPutImage\n"));
-	shm_available = TFALSE;
+	x11_shm_available = TFALSE;
 	return 0;
 }
 
@@ -985,11 +991,11 @@
 						v->shminfo.readOnly = False;
 						XSync(mod->x11_Display, 0);
 						oldhnd = XSetErrorHandler(shm_errhandler);
-						shm_available = TTRUE;
+						x11_shm_available = TTRUE;
 						XShmAttach(mod->x11_Display, &v->shminfo);
 						XSync(mod->x11_Display, 0);
 						XSetErrorHandler(oldhnd);
-						if (shm_available)
+						if (x11_shm_available)
 						{
 							v->imw = w;
 							v->imh = h;
diff -r 7256b8f1b5f9 -r 4eab5b6033cc src/display_x11/display_x11_font.c
--- a/src/display_x11/display_x11_font.c	Thu May 07 14:49:07 2009 +0200
+++ b/src/display_x11/display_x11_font.c	Sun Jun 14 15:06:18 2009 +0200
@@ -68,6 +68,7 @@
 	"FcPatternGetInteger",
 	"FcPatternGetBool",
 	"FcInit",
+	"FcFini",
 };
 
 /*****************************************************************************/
@@ -75,8 +76,8 @@
 ** if initlibxft() succeeds g->use_xft is set to TTRUE
 ** undefining ENABLE_XFT can be used to enforce xlib based font rendering
 */
-TBOOL
-initlibxft(X11DISPLAY *mod)
+
+LOCAL TBOOL x11_initlibxft(X11DISPLAY *mod)
 {
 	#if defined(ENABLE_XFT)
 
@@ -84,9 +85,9 @@
 	int major, minor, first;
  	if (XQueryExtension(mod->x11_Display, "Composite", &major, &minor, &first))
  		return TFALSE;
- 	#endif
 	if (mod->x11_Depth > 24)
 		return TFALSE;


More information about the teklib-general mailing list