Xmt crashes in AskForBool.c?
Brought to you by:
motiftools
I'm debugging a current app, and getting occasional
crashes in Xmt/AskForBool.c at the following line:
XtVaSetValues(info->boolean_internals.icon,
XmtNpixmap, GetPixmap(info-
>boolean_dialog, data.icon_type),
NULL);
I've read the other bug reports and the like re: checking
for a successful return from GetPixmap etc.. but am still
experiencing the crashes. It always happens when it's
handling a dialog box.
any ideas?
Jason Brown
Jason.Brown@aa.com
Logged In: YES
user_id=178930
Please give more details on the crash, i.e. the specific
error message(s), and the platform and OS versions. Without
these details, we cannot determine the problem.
Logged In: YES
user_id=1169338
I just recently ran into another issue with this GetPixmap stuff
that is related to the response I submitted in the other bug
report. BTW, this occurred on a sun box runniong Solaris
2.9. uname: "SunOS sacasip 5.9 Generic_112233-11 sun4u
sparc SUNW,Sun-Fire-480R"
Last year, I set the env var mentioned in that post to fix the
GetPixmap crash. We just came across another related
oddity that I can't quite figure out. If XmtDisplayWarningMsg()
gets called before XmtDisplayWarningAndAsk(), the
GetPixmap crash occurs EVEN IF YOU HAVE THE ENV
VAR SET CORRECTLY!! If XmtDisplayWarningAndAsk()
gets called first, then all is well for the rest of the program's
execution life.
It's as if XmtDisplayWarningMsg() does something to mess-
up the XmGetPixmapByDepth() call. I took a quick look and
didn't see anything obvious jumping out at me. For now, I
just implemented the code change I mentioned in the other
post to check the GetPixmap return value before using it. I
hope to have more time to try to debug this oddity in the
future.
Below is a sample program I wrote to help me isolate and try
to solve the problem. It simply creates a GUI with buttons
that call each of the above mentioned functions.
Click "Warn" first then "Warn and Ask" and you get the
GetPixmap crash. Click them in the other order and
everything is fine. (NOTE: If "Warn and Ask" crashes even if it
is the first button clicked, then you have the bug mentioned in
the previous topic. Make sure the env var is set.)
If you put in the fix to check the GetPixmap return value, then
nothing crashes and you simply get a popup with no "!" icon.
(Sorry if it looks ugly. I just cut and pasted it. May not
lineup nicely in this font.)
-----------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <Xm/PushB.h>
#include <Xmt/Xmt.h>
#include <Xmt/Dialogs.h>
#include <Xmt/Layout.h>
static void warnCb(Widget w, int x,
XmPushButtonCallbackStruct *cb);
static void warnaskCb(Widget w, int x,
XmPushButtonCallbackStruct *cb);
static void quitCb(Widget w, int x,
XmPushButtonCallbackStruct *cb);
static XtAppContext appc;
static Widget toplevel;
static Widget mainLayout;
static Widget warnPb;
static Widget warnaskPb;
static Widget quitPb;
int main( int argc, char** argv )
{
XmString xmStr;
/* Set the env var to ensure that the dialog pixmaps are
found by Xmt. */
/* Would not be hardcoded normally, but do so for this test
program. */
if( putenv
( "XMICONSEARCHPATH=/usr/dt/share/include/bitmaps/%
B" ) ) {
perror("putenv failed for XMICONSEARCHPATH" );
}
/* Start building the display. */
toplevel = XmtInitialize( &appc, "XmtTest", NULL, 0, &argc,
argv,
NULL, NULL, 0);
mainLayout = XtVaCreateWidget( "main_layout",
xmtLayoutWidgetClass,
toplevel,
XmtNorientation, XmVERTICAL,
XmtNlayout, "warn_pb warnask_pb
quit_pb",
NULL );
/* Warning Button */
xmStr = XmStringCreateLocalized( "Warn" );
warnPb = XtVaCreateManagedWidget( "warn_pb",
xmPushButtonWidgetClass,
mainLayout,
XmNlabelString, xmStr,
NULL );
XmStringFree( xmStr );
XtAddCallback( warnPb, XmNactivateCallback,
(XtCallbackProc)warnCb, 0 );
/* Warn and Ask Button */
xmStr = XmStringCreateLocalized( "Warn and Ask" );
warnaskPb = XtVaCreateManagedWidget( "warnask_pb",
xmPushButtonWidgetClass,
mainLayout,
XmNlabelString, xmStr,
NULL );
XmStringFree( xmStr );
XtAddCallback( warnaskPb, XmNactivateCallback,
(XtCallbackProc)warnaskCb, 0);
/* Quit Button */
xmStr = XmStringCreateLocalized( "Quit" );
quitPb = XtVaCreateManagedWidget( "quit_pb",
xmPushButtonWidgetClass,
mainLayout,
XmNlabelString, xmStr,
NULL );
XmStringFree( xmStr );
XtAddCallback( quitPb, XmNactivateCallback,
(XtCallbackProc)quitCb, 0);
/* Display it all */
XtManageChild( mainLayout );
XtRealizeWidget( toplevel );
XtAppMainLoop( appc );
return( 0 );
}
void warnCb( Widget w, int x, XmPushButtonCallbackStruct
*cb )
{
XmtDisplayWarningMsg( mainLayout, NULL,
"This is a WARNING! You have been
warned!",
NULL, NULL );
}
void warnaskCb( Widget w, int x,
XmPushButtonCallbackStruct *cb )
{
XmtDisplayWarningAndAsk( mainLayout, NULL,
"This is a WARNING! Do you feel
warned?",
NULL, NULL, XmtNoButton, NULL );
}
void quitCb( Widget w, int x, XmPushButtonCallbackStruct
*cb )
{
exit( 0 );
}
---------------------------------------------------------------