Operating System - HP-UX
1830657 Members
28704 Online
110015 Solutions
New Discussion

destroying widgets in motif

 
devhariprasad
Advisor

destroying widgets in motif

Does the order of calling XtDestroyWidget() and XtUnmanageChild() matter?

Though XtDestroyWidget() calls XtUnmanageChild() in it, I have an application where cleanup does not happen properly when I just use XtDestroyWidget(). It needs usage of both XtDestroyWidget and XtUnmanageChild or XtUnrealizeWidget(order does not matter here).

Pleae give your thoughts.
2 REPLIES 2
Peter Godron
Honored Contributor

Re: destroying widgets in motif

Hi,
are the children created correctly via the XtManageChildren?

See:
http://lesstif.sourceforge.net/doc/super-ux/g1ae03e/part1/chap3.html
devhariprasad
Advisor

Re: destroying widgets in motif

Yes, the children are created using XtManageChild(). I have herewith attached the cpp program.

2.
2-1. Make the program and run it.
2-2. Fill Form with thirty labels by inputting "30" in the text field next to Data-Num: and pressing "SET" button.

INFO(BEFORE)-------------------------------
(scbar) XmNvalue[0], XmNincrement[10], XmNpageIncrement[72],XmNmaximum[100]
(form) XmNheight[100]
INFO(AFTER)-------------------------------
(scbar) XmNvalue[0], XmNincrement[15], XmNpageIncrement[30],XmNmaximum[455]
(form) XmNheight[455]

2-3. Increment page, the page is incremented by two lines since on line has 15 pixel height.
Pressing the arrow makes the window scroll one line.
By pressing "GET", we see:

INFO(GET)-------------------------------
(scbar) XmNvalue[120], XmNincrement[15],
XmNpageIncrement[30], XmNmaximum[455]
(form) XmNheight[455]

2-4. Input 50 in the text field and press "SET" button, which fills the form with 50 labels.

INFO(BEFORE)-------------------------------
(scbar) XmNvalue[90], XmNincrement[15],
XmNpageIncrement[30], XmNmaximum[755]
(form) XmNheight[755]
INFO(AFTER)-------------------------------
(scbar) XmNvalue[0], XmNincrement[15], XmNpageIncrement[30],XmNmaximum[755]
(form) XmNheight[755]

2-5. Increment page, the page is incremented by two lines since on line has 15 pixel height.
Pressing the arrow makes the window scroll one line.
By pressing "GET", we see:

INFO(GET)-------------------------------
(scbar) XmNvalue[120], XmNincrement[15],
XmNpageIncrement[30], XmNmaximum[455]
(form) XmNheight[455]

2-4. and 2-5. are good case.

2-6. After 2-5., input 30 again in the text field and press "SET" button, which fills the form with 30 labels.

INFO(BEFORE)-------------------------------
(scbar) XmNvalue[210], XmNincrement[15], XmNpageIncrement[30], XmNmaximum[755]
(form) XmNheight[755]
INFO(AFTER)-------------------------------
(scbar) XmNvalue[0], XmNincrement[15], XmNpageIncrement[30], XmNmaximum[455]
(form) XmNheight[455]

2-7. Increment page, the page is incremented by about five lines, which is wrong.
Pressing the arrow makes the window scroll three line, which is wrong, too.
By pressing "GET", we see:

INFO(GET)-------------------------------
(scbar) XmNvalue[117], XmNincrement[45], XmNpageIncrement[72],XmNmaximum[455]
(form) XmNheight[455]

By adding "XtUnmanageChild(vctWidget[i])" or
"XtUnrealizeWidget(vctWidget[i])" before "XtDestroyWidget(vctWidget[i])" this problem is not present. It works fine.