XFixesFetchRegion() crashes app

2009-06-23 Thread Kai-Uwe Behrmann

My application attaches a XFixes created reactangle to a window.
Therefore it does a XOpenDisplay() + XFixesCreateRegion() + 
XCloseDisplay() inside one short function and done.

After the above outlined function resturns a call to XFixesFetchRegion()
from a outside observer forces the application to quit:

PropertyNotify : _NET_COLOR_REGIONSv  679x580+642+245  2
X Error of failed request:  179
  Major opcode of failed request:  155 (XFIXES)
  Minor opcode of failed request:  19 (XFixesFetchRegion)
  Serial number of failed request:  7927
  Current serial number in output stream:  7927

Any idea how to avoid a quit from XFixesFetchRegion()? A error message 
would be enough. A exit in not acceptable to the application.


A minimal example application source code is attached.


kind regards
Kai-Uwe Behrmann
--
developing for colour management 
www.behrmann.name + www.oyranos.org
/* !cc -Wall -g -o test_XFixes test_XFixes.c -lXfixes -lX11 */
#include X11/Xlib.h
#include X11/extensions/Xfixes.h
#include stdio.h

int main(int argc, char * argv[])
{
  Display * display = XOpenDisplay(0);
  XRectangle rec[2] = { { 0,0,0,0 }, { 0,0,0,0 } },
   * rect = 0;
  int nRect = 0;
  XserverRegion reg = 0;

  rec[0].x = 10;
  rec[0].y = 20;
  rec[0].width = 30;
  rec[0].height = 40;

  reg = XFixesCreateRegion( display, rec, 1);
  rect = XFixesFetchRegion( display, reg, nRect );
  if(!nRect)
printf( no region to be found %d\n, (int)reg );
  else
printf( rect found[%d]: %dx%d+%d+%d\n, (int)reg,
rect-width, rect-height, rect-x, rect-y );

  XCloseDisplay( display ); display = 0;
  printf( close display\n\n );

  /* reopen */
  printf( reopening display and fetching the same region[%d]\n\n, (int)reg );
  display = XOpenDisplay(0);
  nRect = 0;
  rect = XFixesFetchRegion( display, reg, nRect );
  if(!nRect)
printf( no region to be found %d\n, (int)reg );
  else
printf( rect found: %dx%d+%d+%d\n,
rect-width, rect-height, rect-x, rect-y );

  XCloseDisplay( display ); display = 0;

  return 0;
}
___
xorg mailing list
xorg@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/xorg

Re: XFixesFetchRegion() crashes app

2009-06-23 Thread Maarten Maathuis
Common sense (and the fact that the error says BadRegion here) suggest that

  reg = XFixesCreateRegion( display, rec, 1);

This region number is no longer valid after you close the display.

Doing this a 2nd time after setting nRect = 0 will fix it.

Maarten.
___
xorg mailing list
xorg@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/xorg


Re: XFixesFetchRegion() crashes app

2009-06-23 Thread Kai-Uwe Behrmann
Am 23.06.09, 11:35 +0200 schrieb Maarten Maathuis:
 Common sense (and the fact that the error says BadRegion here) suggest that

  reg = XFixesCreateRegion( display, rec, 1);

 This region number is no longer valid after you close the display.

 Doing this a 2nd time after setting nRect = 0 will fix it.

Other than I expected XFixesCreateRegion()/XFixesFetchRegion() is not 
useful for inter application communication.

Thanks for the quick answere.

kind regards
Kai-Uwe Behrmann
-- 
developing for colour management 
www.behrmann.name + www.oyranos.org

___
xorg mailing list
xorg@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/xorg


Re: XFixesFetchRegion() crashes app

2009-06-23 Thread Maarten Maathuis
Please don't think i know what you are actually trying to do, i solved
this like you would a puzzle. First guess happened to work.

Maarten.
___
xorg mailing list
xorg@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/xorg


Re: XFixesFetchRegion() crashes app

2009-06-23 Thread Maarten Maathuis
And this region is some property of the root window?
___
xorg mailing list
xorg@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/xorg


Re: XFixesFetchRegion() crashes app

2009-06-23 Thread Eirik Byrkjeflot Anonsen
Kai-Uwe Behrmann k...@gmx.de writes:

 My application attaches a XFixes created reactangle to a window.
 Therefore it does a XOpenDisplay() + XFixesCreateRegion() +
 XCloseDisplay() inside one short function and done.
 After the above outlined function resturns a call to XFixesFetchRegion()
 from a outside observer forces the application to quit:

 PropertyNotify : _NET_COLOR_REGIONSv  679x580+642+245  2
 X Error of failed request:  179
   Major opcode of failed request:  155 (XFIXES)
   Minor opcode of failed request:  19 (XFixesFetchRegion)
   Serial number of failed request:  7927
   Current serial number in output stream:  7927

 Any idea how to avoid a quit from XFixesFetchRegion()? A error message
 would be enough. A exit in not acceptable to the application.

My memory is rather unclear on this point, but if the default error
handler exits the program, the solution could be to install your own
error handler with XSetErrorHandler()

eirik
___
xorg mailing list
xorg@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/xorg


Re: XFixesFetchRegion() crashes app

2009-06-23 Thread Kai-Uwe Behrmann
Am 23.06.09, 13:10 +0200 schrieb Eirik Byrkjeflot Anonsen:
 Kai-Uwe Behrmann k...@gmx.de writes:
 Any idea how to avoid a quit from XFixesFetchRegion()? A error message
 would be enough. A exit in not acceptable to the application.

 My memory is rather unclear on this point, but if the default error
 handler exits the program, the solution could be to install your own
 error handler with XSetErrorHandler()

man XSetErrorHandler is the right pointer. Thanks.

kind regards
Kai-Uwe Behrmann
-- 
developing for colour management 
www.behrmann.name + www.oyranos.org

___
xorg mailing list
xorg@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/xorg