XtManageChild broken???

Ciccotelli Massimo ciccotelli@cesi.it
Wed Jun 19 06:52:00 GMT 2002


Hi all,
I have a port of a Linux application on Cygwin which worked fine using 
XFree version 4.1.0.

Executing the code after recompiling with version 4.2.0 it crashes 
(segmentation fault) when I try to open a menu.

I have tried to identify the problem (unfortunately I am not an X11 
expert); it seems due to a call of
XtManageChild !!!

Digging around in the Internet I have found a simple example which shows 
the same behaviour of my application. the code is the following:

#include <Xm/Xm.h>
#include <Xm/MainW.h>
#include <Xm/CascadeB.h>
#include <Xm/MessageB.h>
#include <Xm/PushB.h>

main(int argc, char *argv[])
{
    XtAppContext app;
    Widget top_wid, main_w, menu_bar, info, quit;


    /* callback for the pushbuttons.  pops up dialog */
    void info_pop_up(), quit_pop_up(); 
       
    top_wid = XtVaAppInitialize(&app, "Demos", NULL, 0,
        &argc, argv, NULL, NULL);

    main_w = XtVaCreateManagedWidget("main_window",
        xmMainWindowWidgetClass,   top_wid,
        XmNheight, 300,
        XmNwidth,300,
        NULL);

    menu_bar = XmCreateMenuBar(main_w, "main_list",
        NULL, 0);       
    XtManageChild(menu_bar);


    /* create quit widget + callback */
       
    quit = XtVaCreateManagedWidget( "Quit",
        xmCascadeButtonWidgetClass, menu_bar,
        XmNmnemonic, 'Q',
        NULL);
       
    /* Callback has data passed to */
   
    XtAddCallback(quit, XmNactivateCallback, quit_pop_up,
                   "Are you sure you want to quit?");

    XtRealizeWidget(top_wid);
    XtAppMainLoop(app);
}

void
quit_pop_up(Widget cascade_button, char *text,
XmPushButtonCallbackStruct *cbs)

{
    Widget dialog;
    XmString xm_string;
    void quit_activate();
    Arg args[1];

    /* label the dialog */
    xm_string = XmStringCreateSimple(text);
    XtSetArg(args[0], XmNmessageString, xm_string);


    /* Create the WarningDialog */
    dialog = XmCreateWarningDialog(cascade_button, "quit",
                                   args, 1);

    XmStringFree(xm_string);

    XtAddCallback(dialog, XmNokCallback, quit_activate,
                  NULL);

    XtManageChild(dialog);     // This call crashes the application.
    XtPopup(XtParent(dialog), XtGrabNone);
}


/* callback routines for dialogs */

void
quit_activate(Widget dialog)
{
    printf("Quit Ok was pressed.\n");
    exit(0);
}

This code compiles and run fine in my Linux (RH7.1) box.

Is it a bug???
Am I missing something??

I'm using cygwin 1.3.10 on Win98/Win NT 4 sp6

Thanks a lot,
Massimo



More information about the Cygwin-xfree mailing list