summaryrefslogtreecommitdiff
path: root/src/lib/ximage.c
diff options
context:
space:
mode:
authorKim Woelders <kim@woelders.dk>2010-02-20 11:51:04 +0000
committerKim Woelders <kim@woelders.dk>2010-02-20 11:51:04 +0000
commit08183bec3fbd5f4821e9f7ac06a5c619266b8e61 (patch)
tree0824116427223d6bf361491a3c00c514b50c2fed /src/lib/ximage.c
parent7bf03a945c5a71015e4e5ff6622d1cba1ad2aaf0 (diff)
downloadimlib2-08183bec3fbd5f4821e9f7ac06a5c619266b8e61.tar.gz
Only check XShmAttach once in __imlib_ShmGetXImage().
SVN revision: 46334
Diffstat (limited to 'src/lib/ximage.c')
-rw-r--r--src/lib/ximage.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/lib/ximage.c b/src/lib/ximage.c
index ece1635..5d7103f 100644
--- a/src/lib/ximage.c
+++ b/src/lib/ximage.c
@@ -38,7 +38,7 @@ __imlib_ShmCheck(Display * d)
{
/* if its there set x_does_shm flag */
if (XShmQueryExtension(d))
- x_does_shm = 1;
+ x_does_shm = 2; /* 2: __imlib_ShmGetXImage tests first XShmAttach */
/* clear the flag - no shm at all */
else
x_does_shm = 0;
@@ -69,17 +69,25 @@ __imlib_ShmGetXImage(Display * d, Visual * v, Drawable draw, int depth,
{
XErrorHandler ph;
- /* setup a temporary error handler */
- _x_err = 0;
- ph = XSetErrorHandler((XErrorHandler) TmpXError);
+ if (x_does_shm == 2)
+ {
+ /* setup a temporary error handler */
+ _x_err = 0;
+ XSync(d, False);
+ ph = XSetErrorHandler((XErrorHandler) TmpXError);
+ }
/* ask X to attach to the shared mem segment */
XShmAttach(d, si);
if (draw != None)
XShmGetImage(d, draw, xim, x, y, 0xffffffff);
- /* wait for X to reply and do this */
- XSync(d, False);
- /* reset the error handler */
- XSetErrorHandler((XErrorHandler) ph);
+ if (x_does_shm == 2)
+ {
+ /* wait for X to reply and do this */
+ XSync(d, False);
+ /* reset the error handler */
+ XSetErrorHandler((XErrorHandler) ph);
+ x_does_shm = 1;
+ }
/* if we attached without an error we're set */
if (_x_err == 0)