1 #if 0
2 To:          lesstif@lesstif.org
3 From:        Steven G. Kargl <kargl@troutmask.apl.washington.edu>
4 Subject:     MainW.c is killing me.
5 Date:        Tue, 7 Sep 1999 14:43:31 -0700 (PDT)
6 
7 Its me, again.
8 
9 Well, I spent all weekend trying to understand MainW.c, testall,
10 and why my patch from last week failed to fix dynapix.  I forgot
11 a MainWindow could be a child widget to some other manager widget.
12 Doh!
13 
14 So, I download lesstif-current with a date of 990907.  I do not
15 alter any sources.
16 
17 The following program when compiled and linked against Lesstifs
18 1.2 library produces a segmentation fault.  It compiles and runs
19 with OSF Motif 1.2.
20 #endif
21 
22 
23 #include <Xm/MainW.h>
24 
main(int argc,char * argv[])25 int main(int argc, char *argv[]) {
26 
27 	Widget toplevel, main1, main2, menu1, menu2;
28 	XtAppContext app;
29 	XmString text;
30 
31 	XtSetLanguageProc(NULL, NULL, NULL);
32 
33 	toplevel = XtVaAppInitialize(&app, "t", NULL, 0, &argc, argv,
34         NULL, NULL);
35 
36 	main1 = XtVaCreateManagedWidget("main1",
37         xmMainWindowWidgetClass, toplevel,
38         XmNscrollBarDisplayPolicy, XmAS_NEEDED,
39 		XmNscrollingPolicy, XmAUTOMATIC,
40         NULL);
41 
42 	main2 = XtVaCreateManagedWidget("main2",
43         xmMainWindowWidgetClass, main1,
44         NULL);
45 
46     text = XmStringCreateLocalized("Menu2");
47     menu2 = XmVaCreateSimpleMenuBar(main2, "menu2",
48 		XmVaCASCADEBUTTON, text, 'e', NULL);
49     XmStringFree(text);
50     XtManageChild(menu2);
51 
52 	XtVaSetValues(main2, XmNmenuBar, menu2, XmNwidth, 150, XmNheight, 130,
53         NULL);
54 
55     text = XmStringCreateLocalized("Menu1");
56     menu1 = XmVaCreateSimpleMenuBar(main1, "menu1",
57 		XmVaCASCADEBUTTON, text, 'M', NULL);
58     XmStringFree(text);
59     XtManageChild(menu1);
60 
61 #if 1
62 	XtVaSetValues(main1,
63 		XmNmenuBar, menu1,
64 		XmNworkWindow, main2,
65 		NULL);
66 #else
67 	XmMainWindowSetAreas(main1, menu1, NULL, NULL, NULL, main2);
68 #endif
69 
70 	XtRealizeWidget(toplevel);
71 
72 /* Note: the following values are the result of
73  * querying the current geometry.
74  */
75 {
76 static XtWidgetGeometry Expected[] = {
77    CWWidth | CWHeight            ,  232,  387,  131,  162, 0,0,0, /* main1 */
78    CWWidth | CWHeight | CWX | CWY,    4,   35,  100,  100, 0,0,0, /* ClipWindow */
79    CWWidth | CWHeight | CWX | CWY,    0,    0,  150,  130, 0,0,0, /* main2 */
80    CWWidth | CWHeight | CWX | CWY,    0,    0,  150,   31, 0,0,0, /* menu2 */
81    CWWidth | CWHeight | CWX | CWY,    5,    5,   46,   21, 0,0,0, /* button_0 */
82    CWWidth | CWHeight | CWX | CWY,  112,   31,   19,  108, 0,0,0, /* VertScrollBar */
83    CWWidth | CWHeight | CWX | CWY,    0,  143,  108,   19, 0,0,0, /* HorScrollBar */
84    CWWidth | CWHeight | CWX | CWY,    0,    0,  131,   31, 0,0,0, /* menu1 */
85    CWWidth | CWHeight | CWX | CWY,    5,    5,   46,   21, 0,0,0, /* button_0 */
86 };
87 /* toplevel should be replaced with to correct applicationShell */
88 PrintDetails(toplevel, Expected);
89 }
90 LessTifTestMainLoop(toplevel);
91     return 0;
92 }
93 
94 
95 #if 0
96 troutmask:kargl[211] t -sync
97 Segmentation fault (core dumped)
98 troutmask:kargl[212] gdb t t.core
99 GNU gdb 4.18
100 Copyright 1998 Free Software Foundation, Inc.
101 GDB is free software, covered by the GNU General Public License, and you are
102 welcome to change it and/or distribute copies of it under certain conditions.
103 Type "show copying" to see the conditions.
104 There is absolutely no warranty for GDB.  Type "show warranty" for details.
105 This GDB was configured as "i386-unknown-freebsd"...
106 Core was generated by t.
107 Program terminated with signal 11, Segmentation fault.
108 #0  0x80485f1 in set_values (old=0xbfbfd2bc, request=0xbfbfcf9c,
109     new_w=0x81e0000, args=0x81ddfa0, num_args=0xbfbfcdb0) at MainW.c:470
110 470             if (SW_VisualPolicy(new_w) == XmCONSTANT &&
111 (gdb) bt
112 #0  0x80485f1 in set_values (old=0xbfbfd2bc, request=0xbfbfcf9c,
113     new_w=0x81e0000, args=0x81ddfa0, num_args=0xbfbfcdb0) at MainW.c:470
114 #1  0x80caf1d in CallSetValues ()
115 #2  0x80cb303 in XtSetValues ()
116 #3  0x80d7d8c in XtVaSetValues ()
117 #4  0x804826b in main (argc=1, argv=0xbfbfd674) at t.c:39
118 #5  0x80480ec in _start ()
119 (gdb) quit
120 
121 --
122 Steve
123 #endif
124