[AD] X shutdown sequence

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Right now if you exit an X Allegro program then has been configured to
use SIGALRM instead of threads, it will say something like:

	Xlib: unexpected async reply (sequence 0xb4)!

This patch aims to stop that.  The hack is because the two different
bg_mans act differently where shutting down X is concerned.  The
SIGALRM driver needs to be put on hold during `XCloseDisplay', but the
pthreads driver needs to be unlocked during `XCloseDisplay'.
Index: src/x/xsystem.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/x/xsystem.c,v
retrieving revision 1.18
diff -u -r1.18 xsystem.c
--- src/x/xsystem.c	2001/11/06 17:16:41	1.18
+++ src/x/xsystem.c	2001/11/20 01:59:44
@@ -213,7 +213,6 @@
  */
 static void _xwin_sysdrv_exit(void)
 {
-   _xwin_destroy_window();
    _xwin_close_display();
    _unix_bg_man->exit();
 
Index: src/x/xwin.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/x/xwin.c,v
retrieving revision 1.38
diff -u -r1.38 xwin.c
--- src/x/xwin.c	2001/11/09 09:48:32	1.38
+++ src/x/xwin.c	2001/11/20 01:59:51
@@ -326,18 +326,26 @@
  */
 void _xwin_close_display(void)
 {
-   XLOCK();
+   /* Oh gawd, what is that smell?  */
+   int locking = 1;
+#ifdef HAVE_LIBPTHREAD
+   if (_unix_bg_man == &_bg_man_pthreads)
+      locking = 0;
+#endif
 
-   _xwin_private_destroy_window();
+   if (locking) {
+      XLOCK();
+   }
 
    if (_xwin.display != 0) {
-      /* Must unlock display before closing.  */
-      XUNLOCK();
+      _xwin_destroy_window();
       XCloseDisplay(_xwin.display);
       _xwin.display = 0;
    }
-   else
+
+   if (locking) {
       XUNLOCK();
+   }
 }
 
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/