Hello,
I have been experiencing random crashes when attempting to raise a custom message dialog. The point of disaster occurs at one of the following lines
of code within the OKDialog function (sometimes the first line and at other times the second).
void OKDialog (Widget dialog...)
{
/* ...Code to customize dialog */
XtManageChild (dialog);
XtPopup (XtParent (dialog), XtGrabNone);
}
Upon crashing I receive one of the following errors "XtPopup requires a subclass of shellWidgetClass", or "Attempt to manage a child when parent is not Composite" or no error message at all. Most times there will be no crash and the dialog will appear.
I have been using the this OKDialog all over the place with no problems up till now. The only difference in this recent case is that there can now be multiple instances of parent widget (for the OK dialog). So I can have parent_instance_1 and parent_instance_2 and launch the OKDialog from one of these two instance forms. Maybe the OKdialog is being confused by which parent it belongs to? Thanks for any help on this topic.
You don`t say what the dialog is, but from your code and from the description of the crash, it appears that it is *not* (wait -- let me try that as not) what Motif terms a "dialog". That is, it is probably a manager widget or a push-button but not a subclass of XmBulletinBoard parented by an XmDialogShell.This widget is the one returned by the convenience routines such as XmCreateTemplateDialog(); you get a handle to the top-level manager widget which is a child of the shell of the appropriate type. Subsequently, when you XtManageChild() that widget, Motif manages -- and pops up -- the parent shell, which you don`t need to deal with directly.
I would go through this code using XmIsSubclass() and the matching routines for each class to ensure that your parenting and widget types are what you expect. You can also look at the code in the debugger, more easily, by dereferencing the widget pointer to see what class pointer is embedded in the widget data structure. But Xt should be consistent in issuing errors.
The other clue that pops out from the segment of code that you posted is that you seem to be re-using widgets and the dialog. In that case, perhaps one of the widgets in the hierarchy has already been destroyed, and Xt is sometimes correctly and sometimes incorrectly dereferencing a chunk of memory which no longer really exists; i.e. you are using a destroyed widget. For tips on catching this easily, read at http//www.motifzone.com/tmd/tmd_tip_archive.html or tmd_tips_archive.html about catching object references after they`ve been destroyed. I think this is the likeliest explanation.
"For tips on catching this easily, read at http//www.motifzone.com/tmd/tmd_tip_archive.html or tmd_tips_archive.html about catching object references after they`ve been destroyed."
Or you could just click the "Tips and Tricks" link over on the left there )
Thanks. The problem did involve the destruction of widgets. I can go to sleep now.