Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!pacbell.com!ucsd!ucbvax!unipalm.co.uk!richard From: richard@unipalm.co.uk Newsgroups: comp.windows.x.motif Subject: Bug in Sash with multiple displays Message-ID: <9102121454.AA17703@ariel.unipalm.co.uk> Date: 12 Feb 91 14:54:39 GMT Sender: daemon@ucbvax.BERKELEY.EDU Distribution: inet Organization: The Internet Lines: 99 OSF Problem Report ================================= Submitter Name: Richard Nuttall Organization: Unipalm Limited Email Address: richard@unipalm.co.uk Phone: +44 954 211797 OSF License Number: 845-F-S-90 Hardware/Software Configuration - ------------------------------- Offering and Version: Motif 1.1.0.2 Component (Module): Xm Sash.c Client Hardware: SPARCstation 1+ Client Software: SunOS 4.1 Server Hardware: SPARCstation 1/GX, Sun3/60 Server Software: Unipalm XTech X11R4 + 1-18. Compiler: SunOS 4.1 cc Problem Description - ------------------- Severity Level: Fatal Date of First Occurrence: 12-Feb-91 One Line Description: Sash caches the crosshair cursor, which doesn't work for multiple displays. Full Description: The crosshair cursor used by the Sash is created only once and then the same cursor is returned for future Sashes. Since the cursor created is display specific, A protocol error results when trying to realise a Sash on more than one display from the same application. Repeat By: (edited fragments from large program) [...] dpy1 = XtOpenDisplay(...,"machine1:0",....); dpy2 = XtOpenDisplay(...,"machine2:0",....); top1 = XtAppCreateShell("Shell1", "Xapp", applicationShellWidgetClass, dpy1, NULL, 0); top2 = XtAppCreateShell("Shell2", "Xapp", applicationShellWidgetClass, dpy2, NULL, 0); [...] PW1 = XmCreatePanedWindow(top1, "PW1", NULL, 0); PW2 = XmCreatePanedWindow(top2, "PW2", NULL, 0); [...] XtRealizeWidget(top1); XtRealizeWidget(top2); /* error occurs here */ Proposed Solution: (Quick hack) *** /bold/files/motif/sun4/lib/Xm/Sash.c Mon Oct 9 10:50:01 1989 --- Sash.c Tue Feb 12 14:08:32 1991 *************** *** 254,261 **** } - static Cursor SashCursor=NULL; - static void Realize(w, p_valueMask, attributes) register Widget w; Mask *p_valueMask; --- 254,259 ---- *************** *** 262,270 **** XSetWindowAttributes *attributes; { Mask valueMask = *p_valueMask; - if (SashCursor==NULL) - SashCursor=XCreateFontCursor(XtDisplay(w), XC_crosshair); attributes->cursor = SashCursor; valueMask |= CWCursor; --- 260,267 ---- XSetWindowAttributes *attributes; { Mask valueMask = *p_valueMask; + Cursor SashCursor = XCreateFontCursor(XtDisplay(w), XC_crosshair); attributes->cursor = SashCursor; valueMask |= CWCursor; A better solution would be to check the display and cache one cursor per display. I have not considered any memory leaks that might be caused by creating lots of cursors but not destroying them.