discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Application shutdown crashes


From: Alexander Malmberg
Subject: Application shutdown crashes
Date: Tue, 17 Sep 2002 00:22:57 +0200

Hi,

I've managed to track down the (hopefully it's the only one) crash that
occurs sometimes when applications exit. Turns out that it's a known,
but from what I can tell unfixed, bug in XFree86's XIM code. A
description can be found here:

http://www.xfree86.org/pipermail/xpert/2002-June/018370.html

I've attached a workaround. It would be cleaner if the bug was fixed and
everyone upgraded, but that's a pretty unreasonable thing to expect, so
in the interest of compatibility, I think it should be applied.

Also, [XIMInputServer -dealloc] doesn't call [super dealloc], which I
assume is a bug (though this patch doesn't fix it).

- Alexander Malmberg
Index: Headers/x11/XGInputServer.h
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/back/Headers/x11/XGInputServer.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 XGInputServer.h
--- Headers/x11/XGInputServer.h 27 Mar 2002 23:45:33 -0000      1.1.1.1
+++ Headers/x11/XGInputServer.h 16 Sep 2002 19:48:04 -0000
@@ -45,6 +45,9 @@
   XIMStyle  xim_style;
   NSMutableData   *dbuf;
   NSStringEncoding encoding;
+
+  XIC      *xics;
+  int       num_xics;
 }
 
 - (id) initWithDelegate: (id)aDelegate
Index: Source/x11/XIMInputServer.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/back/Source/x11/XIMInputServer.m,v
retrieving revision 1.5
diff -u -r1.5 XIMInputServer.m
--- Source/x11/XIMInputServer.m 15 Jul 2002 03:11:11 -0000      1.5
+++ Source/x11/XIMInputServer.m 16 Sep 2002 19:48:04 -0000
@@ -35,6 +35,7 @@
 #include "x11/XGInputServer.h"
 #include <X11/Xlocale.h>
 
+
 @interface XIMInputServer (XIMPrivate)
 - (BOOL) ximInit: (Display *)dpy;
 - (void) ximClose;
@@ -109,6 +110,7 @@
   DESTROY(server_name);
   DESTROY(dbuf);
   [self ximClose];
+  /* !! BUG !! */
 }
 
 /* ----------------------------------------------------------------------
@@ -277,7 +279,17 @@
 
 - (void) ximClose
 {
+  int i;
+  for (i=0;i<num_xics;i++)
+    {
+      XDestroyIC(xics[i]);
+    }
+  free(xics);
+  num_xics=0;
+  xics=NULL;
+
   NSDebugLLog(@"XIM", @"Closed XIM\n");
+
   if (xim)
     XCloseIM(xim);
   xim=NULL;
@@ -316,6 +328,9 @@
                  xim_style, NULL);
   if (xic==NULL)
     NSDebugLLog(@"XIM", @"Can't create the input context.\n");
+
+  xics = realloc(xics, sizeof(XIC) * (num_xics + 1));
+  xics[num_xics++] = xic;
   return xic;
 }
 
@@ -330,6 +345,21 @@
 
 - (void) ximCloseIC: (XIC)xic
 {
+  int i;
+  for (i = 0; i < num_xics; i++)
+    {
+      if (xics[i] == xic)
+        break;
+    }
+  if (i == num_xics)
+    {
+      NSLog(@"internal error in ximCloseIC: can't find XIC in list");
+      abort();
+    }
+  for (i++; i < num_xics; i++)
+    xics[i - 1] = xics[i];
+  num_xics--;
+
   XDestroyIC(xic);
 }
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]