Re: [AD] [XWIN] SHM bug.

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


> > I don't know very well how X and threads interact, so I can't say if
> > it's a synchronization problem between two threads that are racing
> > for locking the X server or simply a problem that originates in XLOCK()
> > itself.

Neither :-) The problem has nothing to do with threads.

> except my major problem is whenever Im just writing to the screen. If I
> try anything but 'blit' (ie: line, clear, textout, etc...) I get that
> 'BadAccess' error. Although the problem you pointed out does show it's
> head now and then.

The following patch fixes my own problem:

--- cvsroot/allegro/src/x/xwin.c Sat Feb  9 13:29:47 2002
+++ src/allegro/src/x/xwin.c Mon Mar 11 23:34:45 2002
@@ -1103,8 +1103,10 @@
     _xwin.shminfo.readOnly = True;

     /* Attach shared memory to the X-server address space.  */
-    if (XShmAttach(_xwin.display, &_xwin.shminfo))
+    if (XShmAttach(_xwin.display, &_xwin.shminfo)) {
+                     XSync(_xwin.display, False);
        break;
+           }

     shmdt(_xwin.shminfo.shmaddr);
         }

Could you try it ?

If it's not sufficient, add this one:

--- cvsroot/allegro/src/x/xwin.c Sat Feb  9 13:29:47 2002
+++ src/allegro/src/x/xwin.c Mon Mar 11 23:34:45 2002
@@ -2286,7 +2288,7 @@
 #ifdef ALLEGRO_XWINDOWS_WITH_SHM
       if (_xwin.use_shm)
   XShmPutImage(_xwin.display, _xwin.window, _xwin.gc, _xwin.ximage,
-        x + _xwin.scroll_x, y + _xwin.scroll_y, x, y, w, h, False);
+        x + _xwin.scroll_x, y + _xwin.scroll_y, x, y, w, h, True);
       else
 #endif
   XPutImage(_xwin.display, _xwin.window, _xwin.gc, _xwin.ximage,

It instructs XShmPutImage() to send a XShmCompletionEvent. Maybe can this
help Allegro to properly synchronize with the X server.

--
Eric Botcazou
ebotcazou@xxxxxxxxxx



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