This is the mail archive of the cygwin-xfree@cygwin.com mailing list for the Cygwin XFree86 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: XtManageChild broken???


Massimo,

Unfortunately I know nothing about Xt and apparently no one else on the list
does either, or at least they haven't run into your same problem.

We haven't made any Cygwin-specific changes to the Xt code in XFree86 so it
wouldn't have been by our doing that something is now broken.  Granted,
there may have been changes to Xt that required a missing change on our
part, but then we wouldn't know if that was the case, would we? :)

You can always do whatever I do when I've got a problem:
1) Scour any documentation that I've got, reading and re-reading it until I
know for a fact that what I have programmed is 100% correct.
2) Scour google.com for any additional information I can find.
3) Take a look at the source code for the library, in your case Xt.
4) Do a debug build of Cygwin/XFree86 (following the instructions in the
Contributor's Guide) and run my application in gdb so I can step through
until I see the crash.
5) Try to rewrite my program to be "safer".  That is, try to do things that
the documentation doesn't explicitly mention but that will probably not
hurt.  For example, in Windows you might throw in a call to UpdateWindow
following your first call to ShowWindow if you were having problems where
your program didn't paint on launch; some documentation may leave out this
detail that calling UpdateWindow is logically necessary.
6) Repeat 1 through 5 until the problem is corrected.

Know this: a sample program working on Linux but failing on Cygwin doesn't
mean that the sample program is correctly implemented.  In my experience I
have seen Cygwin react more catastrophically to simple programming errors,
whereas Linux seems to be pretty tolerant of mistakes.  I have no idea why
this is the case, but that just seems to be the pattern.  This is kind of
like saying "my program works just fine with no optimization, but with -O2
is segfaults"... sometimes a simple change in the underlying layers can make
a fault more evident.

Good luck,

Harold

P.S. The Cygwin/XFree86 Contributor's Guide is here:
http://xfree86.cygwin.com/docs/cg/

> -----Original Message-----
> From: cygwin-xfree-owner@cygwin.com
> [mailto:cygwin-xfree-owner@cygwin.com]On Behalf Of Ciccotelli Massimo
> Sent: Wednesday, June 19, 2002 9:52 AM
> To: cygwin-xfree@cygwin.com
> Subject: XtManageChild broken???
>
>
> 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
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]