From 8c82442c6fcdc29663ad902125cb697a3f1f50e2 Mon Sep 17 00:00:00 2001 From: iovar Date: Mon, 4 Dec 2006 17:50:45 +0000 Subject: Added custom X error handler, to avoid BadWindow on XGetWindowAttributes, with XQueryTree git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@210 f606c939-3180-4ac9-a4b8-4b8779d57d0a --- recordmydesktop/src/capture_sound.c | 1 - recordmydesktop/src/poll_damage.c | 19 ++++++++++++++++++- recordmydesktop/src/recordmydesktop.c | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/recordmydesktop/src/capture_sound.c b/recordmydesktop/src/capture_sound.c index f9a7675..702d325 100644 --- a/recordmydesktop/src/capture_sound.c +++ b/recordmydesktop/src/capture_sound.c @@ -33,7 +33,6 @@ void *CaptureSound(ProgData *pdata){ // fprintf(stderr,"fr %d ps %d\n",frames,pdata->periodsize);fflush(stderr); pthread_mutex_t pmut; pthread_mutex_init(&pmut,NULL); - pdata->sound_buffer=NULL; while(pdata->running){ int sret=0; diff --git a/recordmydesktop/src/poll_damage.c b/recordmydesktop/src/poll_damage.c index 09de911..d03f78d 100644 --- a/recordmydesktop/src/poll_damage.c +++ b/recordmydesktop/src/poll_damage.c @@ -27,6 +27,21 @@ #include +int rmdErrorHandler( Display *dpy, XErrorEvent *e ) +{ + char error_desc[1024]; + XGetErrorText(dpy,e->error_code,error_desc,sizeof(error_desc)); + fprintf(stderr,"X Error: %s\n",error_desc); + fflush(stderr); + if((e->error_code==BadWindow)&&(e->request_code==X_GetWindowAttributes)){ + fprintf(stderr,"BadWindow on XGetWindowAttributes.\nIgnoring..."); + fflush(stderr); + return 0; + } + else + exit(1); +} + void *PollDamage(ProgData *pdata){ Window root_return, parent_return, @@ -36,6 +51,8 @@ void *PollDamage(ProgData *pdata){ inserts=0; XEvent event; + XSetErrorHandler(rmdErrorHandler); + XSelectInput (pdata->dpy,pdata->specs.root, SubstructureNotifyMask); XQueryTree (pdata->dpy, @@ -52,7 +69,7 @@ void *PollDamage(ProgData *pdata){ XDamageCreate (pdata->dpy, children[i],XDamageReportRawRectangles); } } - + XFree(children); XDamageCreate( pdata->dpy, pdata->brwin.windowid, XDamageReportRawRectangles); diff --git a/recordmydesktop/src/recordmydesktop.c b/recordmydesktop/src/recordmydesktop.c index ac1ea16..f15bdc9 100644 --- a/recordmydesktop/src/recordmydesktop.c +++ b/recordmydesktop/src/recordmydesktop.c @@ -127,6 +127,7 @@ int main(int argc,char **argv){ pthread_cond_init(&pdata.sound_buffer_ready,NULL); pthread_cond_init(&pdata.sound_data_read,NULL); pdata.list_selector=Paused=Aborted=pdata.avd=0; + pdata.sound_buffer=NULL; pdata.running=1; time_cond=&pdata.time_cond; pause_cond=&pdata.pause_cond; -- cgit v1.2.3