From: paul@hasler.ascom.ch (Paul Breslaw)
Newsgroups: comp.windows.x,comp.windows.x.motif
Subject: Unmapping cascade button causes X error
Date: 27 Sep 92 19:29:48 GMT
Organization: Ascom Hasler AG, CH-3000 Berne 14, Switzerland


HW:    Sun IPX      PC compatible.
OS:    SunOS 4.1.2  Interactive Unix (SysV 3.2).
Motif: 1.1.2        1.0
X11:   R4           R4

Can anyone explain why the following program causes an X BadMatch error?
I get the same effect on both the above HW/SW configurations.

I have a pushbutton whose callback maps a second widget tree consisting
of a shell, a main window, a menubar, and a single cascade button.

The cascade button's callback unmaps the shell subtree. The call to
XtUnmapWidget causes the following X error.

X Error of failed request:  BadMatch (invalid parameter attributes)
  Major opcode of failed request:  42 (X_SetInputFocus)
  Minor opcode of failed request:  0
  Resource id in failed request:  0xb0000e
  Serial number of failed request:  132
  Current serial number in output stream:  134

If I replace the cascadebutton with a pushbutton, although I get complaints
about non-homogeneity in a rowcolumn, the program runs correctly.

Regards

Paul Breslaw (paul@hasler.ascom.ch or paul.breslaw@alcatel.ch)


/********************* CUT HERE **********************************/

/*
 * bug.c - unmapping shell containing cascade button causes X error
*/

/* System includes */
/*******************/

#include <X11/Intrinsic.h>
#include <X11/Shell.h>
#include <Xm/Xm.h>
#include <Xm/MainW.h>
#include <Xm/RowColumn.h>
#include <Xm/Label.h>
#include <Xm/CascadeB.h>
#include <Xm/PushB.h>


/* Local functions */
/*******************/

static void pushCB();
static void hideCB();


/* Local data */
/**************/

static Widget shell;
static Widget push;
static Widget hide;


/* main */
/********/

main( argc, argv )
    int  argc;
    char *argv[];
{
    Widget        toplevel;
    Widget        mainw;
    Widget        row;
    Widget        menu;
    Display      *display;
    XtAppContext  app;

    /* initialize toolkit */

    toplevel = XtVaAppInitialize( &app, "mainw", NULL, 0, &argc, argv, NULL,
                                  NULL );
    display = XtDisplay( toplevel );

    /* create first window */

    push = XtVaCreateManagedWidget( "push", xmPushButtonWidgetClass, toplevel,
                                    NULL );

    XtAddCallback( push, XmNactivateCallback, pushCB, NULL );

    /* create second window */

    shell = XtVaAppCreateShell( NULL, NULL, applicationShellWidgetClass,display,
                                XmNmappedWhenManaged, False,
                                NULL );

    mainw = XtVaCreateManagedWidget( "push", xmMainWindowWidgetClass, shell,
                                    NULL );

    menu = XmCreateMenuBar( mainw, "MenuBar", NULL, 0 );
    XtManageChild( menu );

    hide = XtVaCreateManagedWidget( "hide", xmCascadeButtonWidgetClass, menu,
                                    NULL );

    XtAddCallback( hide, XmNactivateCallback, hideCB, NULL );

    /* realize */

    XtRealizeWidget( shell );
    XtRealizeWidget( toplevel );

    /* run */

    XtAppMainLoop( app );
}


/* pushCB */
/**********/

static void pushCB( w, client_data, call_data )
    Widget  w;
    caddr_t client_data;
    caddr_t call_data;
{
    XtMapWidget( shell );
    XtSetSensitive( push, False );

}


/* hideCB */
/**********/

static void hideCB( w, client_data, call_data )
    Widget  w;
    caddr_t client_data;
    caddr_t call_data;
{
    XtUnmapWidget( shell );         /* <<== this causes X error */
    XtSetSensitive( push, True );
}
Newsgroups: comp.windows.x