|
![](/i/fill.gif) |
Here we go...
POVRay/X11 has code to handle window close and abort rendering
when the window is closed. Unfortunately, the code does not work,
at least not for me.
This patch fixes that. Please apply. Read on below.
----------------------------------------------------------------
--- povray-3.50c/src/unix.cpp 2003-01-07 02:08:30.000000000 +0100
+++ povray-3.50c-ww/src/unix.cpp 2003-11-29 12:09:14.000000000 +0100
@@ -382,7 +386,7 @@
static XColor *GetBestColor PARAMS((long r, long g, long b));
static void SelectVisual PARAMS((Visual **theVisual, unsigned int
*theDepth));
static void BuildColormap PARAMS((Visual *theVisual));
-static Bool HandleXEvents PARAMS((XEvent *theEvent, Bool finished));
+static Bool HandleXEvents PARAMS((Bool finished));
static int HandleXError PARAMS((Display *ErrorDisplay,
XErrorEvent *ErrorEvent));
static int HandleXIOError PARAMS((Display *ErrorDisplay));
@@ -3187,10 +3200,7 @@
/* Sit and handle events until we quit, but don't busy wait */
while (!finished)
{
- XEvent theEvent;
-
- XNextEvent(theDisplay, &theEvent);
- finished = HandleXEvents(&theEvent, True);
+ finished = HandleXEvents(True);
}
}
}
@@ -3220,12 +3230,9 @@
int XWIN_Test_Abort()
{
- XEvent theEvent;
-
- if (theDisplay &&
- XCheckWindowEvent(theDisplay, theWindow, theEVENTMASK, &theEvent))
+ if(theDisplay)
{
- return (HandleXEvents(&theEvent, False) ? true : false);
+ return(HandleXEvents(False) ? true : false);
}
return false;
@@ -3327,7 +3334,7 @@
*
******************************************************************************/
-int HandleXEvents(XEvent *theEvent, Bool finished)
+int HandleXEvents(Bool finished)
{
Bool refresh = False;
Bool abortRender = False;
@@ -3335,9 +3342,20 @@
int refresh_x_max = 0;
int refresh_y_min = theImage->height - 1;
int refresh_y_max = 0;
+ int npending=0;
+ XEvent _theEvent,*theEvent=&_theEvent; // <-- (**)
do
{
+ if(!finished)
+ {
+ /* Process available events; return if no events available. */
+ if(!npending) npending=XPending(theDisplay);
+ if(!npending) break;
+ --npending;
+ }
+ XNextEvent(theDisplay,theEvent);
+
KeySym theKeySym;
#if (X11_DEBUG > 0)
@@ -3465,7 +3510,7 @@
#endif
}
}
- while (XCheckWindowEvent(theDisplay, theWindow, theEVENTMASK, theEvent));
+ while(!finished);
if (refresh && !abortRender)
{
----------------------------------------------------------------
Basically, all I do is replacing XCheckWindowEvent() by XPending() and
XNextEvent(). Furthermore, all event handling is now done in
HandleXEvents() which results in cleaner design. (Previously, the first
event was quieried outside while successive events were queried by
HandleXEvents()).
I tested this patch and it works (linux/X11R6). Should not make trouble
on other OS/releases.
Fixes:
- Closing the window while tracing will now abort the render.
- No events will stay and accumulate in the event queue until end of
rendering.
In case something is unclear or it does not work, feel free to ask me.
Wolfgang
Post a reply to this message
|
![](/i/fill.gif) |