XtPopup core dumping when used with protocol atoms

I have an application that uses popup shells. I manage the window up using XtPopup and XtPopdown. It works fine if, for example, I attach a callback to a button to pop the window up and down. However, I'm trying to overload the "Close" button in the upper left hand corner using a protocol atom (WM_DELETE_WINDOW). Whenever the protocol callback gets invoked (it is the SAME callback I use for the button), it corrupts the contents of my shell widget (shell_widget.core.self become garbage, and shell_widget.core.parent becomes NULL). The next time I try to pop the window up using XtPopup, it core dumps. I have it narrowed down to a very simple test program and the behavior (to my surprise) is very repeatable. I'm not sure if I'm using the protocol atoms incorrectly or what.

Here is how I set up the protocol atom (note - gShell is what was returned from XtVaCreatePopupShell):

// add a callback for the WM_DELETE_WINDOW protocol (close button)
WM_DELETE_MANUAL_WINDOW = XInternAtom( XtDisplay( gShell ),
"WM_DELETE_WINDOW", false );
XmAddWMProtocolCallback( gShell, WM_DELETE_MANUAL_WINDOW,
HideNotify, NULL );

Here is the callback that I invoke via the protocol atom (and from a button on my top level which does work fine):

extern void HideNotify( Widget wid, XtPointer client_data,
XtPointer client_args )
{
static bool show_text = true; // button text flag

if ( true == show_text )
{
// hide window
XtPopdown( gShell );

show_text = false;
} // end show text
else
{
// show window
XtPopup( gShell, XtGrabNone );

show_text = true;
} // end hide text
}

Thanks!


jwobido

jwobido's picture

XtPopup core dumping when used with protocol atoms

Nevermind - I figured out the problem. I need a call to XmAddWMProtocols(). Funny thing is, our software that uses protocols has never had a problem without this call.