Why is my widget still a widget after destruction?

This forum is read only. No new submissions are accepted.

Questions about motif? Contact us

6 posts / 0 new
Last post
Why is my widget still a widget after destruction?

Submitted by Anonymous on Thu, 10/09/2003 - 03:13.

Hi, I have some code that is like this
Widget w = XmCreateFormDialog(...);
and then of course I populate the form with all sorts of goodies. What`s puzzling me is the following. Later in the code, after the dialog created has been closed by clicking the destroy button (not a push button, but the little X-shaped thing in the upper right hand corner of the window, which I assume generates WM_DELETE_WINDOW for the shell), I call the following function.

Bool iscool = XtIsRealized(w);

After this, iscool is true! This greatly surprises me. According to the Motif manual, the default for a TransientShell`s XmNdeleteResponse is XmDESTROY. I assume XtDestroyWidget is called on XtParent(w), which I also believe should call XtDestroyWidget(w). Am I wrong? Also, XtIsRealized(XtParent(w)) returns true!

I am trying to determine if the window containing w has been closed, bottom line. I found that XtIsManaged(w) is false, and am using that as my test, but I`m wondering why XtIsRealized() is not the right thing to call?

Thanks.

Thu, 10/09/2003 - 03:16#1

Thu, 10/09/2003 - 03:16#1

Anonymous

Why is my widget still a widget after destruction?

I forgot to mention, that the first thing that surprised me is that XtIsWidget(w) also returns true after its parent has been presumably destroyed. Bizarre to me... can someone explain this?

 

 

 

Thu, 10/09/2003 - 09:54#2

Anonymous

Why is my widget still a widget after destruction?

First of all, man XtDestroyWidget. Focus on the description of Phase 1 and Phase 2. Especially the part about "when it is safe to do so".

  •  

 

 

 

Thu, 10/09/2003 - 16:46#3

Anonymous

Why is my widget still a widget after destruction?

"First of all," I did read that man page. I focused on all of it and did indeed read the words you quoted. -) I guess I didn`t title my post very well, so you seem to have missed the main point. As I said, my main concern is finding out whether a window has been closed in a safe and consistent manner.
What if I call XtIsMapped() on a widget that has been destroyed? Will I get a segfault? I.e., will motif try to dereference a bad pointer or does it use a lookup table?
Thanks.

  •  

 

 

 

Thu, 10/09/2003 - 20:16#4

Anonymous

Why is my widget still a widget after destruction?

The add a popdownCallback, or destroyCallback to the Shell.

 

Thu, 10/09/2003 - 21:22#5

Thu, 10/09/2003 - 21:22#5

Anonymous

Why is my widget still a widget after destruction?

Funny you should say that. I have actually tried that, but it appears that the widget does not ever get destroyed, which seems to contradict how motif is supposed to act, as I have mentioned elsewhere.
Here is the complete relevant code. Note that DestroyCB never gets called!
Thanks again for your patient help with this.
//=================================================================
/* help text may contain line breaks */
Widget HelpDialog(Widget parent, char *title, char *helptxt, Bool modal){
Widget form =
XmCreateFormDialog(parent, "Information", NULL, 0);
//(title is set in BeBof())

XtVaSetValues(form,
XmNresizePolicy, XmRESIZE_NONE,
XmNwidth, 450,
XmNheight, 500,
NULL);

if (modal)
XtVaSetValues(form,
XmNdialogStyle, XmDIALOG_PRIMARY_APPLICATION_MODAL,
NULL);

if (title)
XtVaSetValues(XtParent(form),
XmNtitle, title,
NULL);

XtManageChild(form);

//created some widgets in here but not modify any properties of "form"
return form;
}

// Elsewhere I call...

_top = HelpDialog(parent, filename, "", modal);
XtVaSetValues((_top),
XmNautoUnmanage, False,
NULL);
/*neither of these are ever called, even when the window is destroyed*/
XtAddCallback(_top, XtNdestroyCallback, DestroyCB, this);
XtAddCallback(XtParent(_top), XtNdestroyCallback, DestroyCB, this);
_tw = XtNameToWidget(_top, "*helptxt");

----------------