Blank windows with multiple instances

I am observing a problem with OpenGL and Xlib functions on Linux. I have an application which creates windows and draws random curves on them. A single instance of this application works fine with any number of windows. However, if I launch 2 instances of this application, one on each core of a dual-core CPU(using setaffinity), I am observing that one window of each instance goes blank and does not draw, while all other windows of both the instances continue drawing the curves properly.

Following is the code snippet:

//To create each window:

dpy = XOpenDisplay( “:0” );
scrnum = DefaultScreen( dpy );
root = RootWindow( dpy, scrnum );
visinfo = glXChooseVisual( dpy, scrnum, attrib );
attr.background_pixel = 0;
attr.border_pixel = 0;
attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone );
attr.event_mask = StructureNotifyMask;
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
win = XCreateWindow( dpy, root, xpos, ypos, width, height,
0, visinfo->depth, InputOutput,
visinfo->visual, mask, &attr );

//Storing the information for each window head:

struct head *h = &Heads[NumHeads];
strcpy( h->DisplayName, name );
h->Dpy = dpy;
h->Win = win;
h->Context = ctx;
h->WinWidth = width;
h->WinHeight = height;

//Event Handling for the created windows (separate function called after creating all the windows):

for ( i = 0; ( ( i < NumHeads ) && ( nowTime < endTime ) ); i++ ) //for all the heads
{
h = &Heads[i];
while ( XPending( h->Dpy ) > 0 && ( nowTime < endTime ) )
{
XNextEvent( h->Dpy, &event );
if ( event.xany.window == h->Win )
{
switch ( event.type )
{
case ConfigureNotify:
Resize( h, event.xconfigure.width, event.xconfigure.height ); //resizes the window
break;
default:
break;
}
time( &nowTime );
}
}
if( Redraw( h ) == -1 ) //draws random curves
{
return -1;
}
time( &nowTime );
}

Tried handling Expose event as well, but that did not help. Moreover, the problem is reproducible only rarely.
Any help in this regard would be greatly appreciated.

I would check to see if you are blocked in XNextEvent, and if so trace from there.

I would check to see if you are blocked in XNextEvent, and if so trace from there. [/QUOTE]

Thanks for the input, but i’m afraid that its not blocked on the XNextEvent. Rather, the Redraw() function is actually called for the window that is apparently blank. But somehow, the second instance is causing one window in each instance to stop drawing. Its as if the head, ‘h’ miraculously becomes invalid for those windows! Tried multiple debugging options. Even called Redraw() from the ConfigureNotify event, and saw that it was called on resizing the window, but even that did not stop the windows from being blank. The wierd part is that all windows were drawing fine until the second instance was launched, so it could not be a case of a corrupt handle as well.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.