Menu usage hangs application

This is a discussion on Menu usage hangs application within the Motif forums, part of the Tools category; Hi, I hope someone can help shed some light on a peculiar problem. I am running my motif application through Exceed and I have a problem that my application hangs ...

Go Back   Unix Linux Forum > Technologies & Tools > Tools > Motif

FixUnix.com - Unix Linux Forums

Unix Content Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-26-2008, 09:47 AM
Default Menu usage hangs application

Hi, I hope someone can help shed some light on a peculiar problem.

I am running my motif application through Exceed and I have a problem
that my application hangs if I click on a menu while my application is
busy running some other operation. I think that the problem arises
because I am inside a callback from motif when I try to access the
menu and somehow the dispatching of queued menu events leaves the
system in an invalid state. It is also possible to recreate this error
when using XWin32 instead of Exceed. It also seems to be reproducable
in other configurations as long as "focus follows click" is used
instead of "focus follows mouse".

In detail, the user pattern that seems to yield the problem is the
following
1. Start some operation that takes a couple of seconds to complete
which effectively locks the thread motif used to make the callback
call
2. While this operation is running, click exactly twice on any menu
header (open menu and close menu). When the operation finally
completes, you can see that the mouse cursor is still in menu
interaction mode (pointing north-east) even though no menu is shown.
Note that the application has not hanged yet.
3. To seal the deal, click on any button in the application to create
the deadlock situation.

I have seen other posts on this news group which reminds me of this
problem but those have more had to do with deadlocks between menues
and forms.

I have recreated my problem just by using a modified textbook motif
example (attached below). The app has one toolbar button "click" and
one menu "File". You get the deadlock by
1. Choose File->Open to start a sleep.
2. During the sleep, click twice on the menu "File". When the sleep
completes, we will have the "north-east" mouse cursor.
3. Click the button "Click"
and the system is locked

I'm hoping that one of you can tell me what's going on here, or even
better, how to solve it

br, Stefan

#include
#include

#include
#include
#include
#include
#include
#include

const char *TRIGGER_HANG = "\
Press the File->Open menu.\n\
Within 5 seconds, press the File menu button exactly twice.\n\
After 5 seconds, click the Click button.\n";

XtAppContext context;
XmStringCharSet char_set=XmSTRING_DEFAULT_CHARSET;

Widget toplevel, form, menu_bar, click, file_menu, open_item,
quit_item;

/* callback routine used for all menus */
void menuCB(Widget w,char* client_data,XmAnyCallbackStruct *call_data)
{
if (strcmp(client_data, "Quit") == 0)
exit(0);
if (strcmp(client_data, "Open") == 0) {
printf("Working...\n");
sleep(5); // Press the File menu twice during this sleep
printf("Done\n");
}
}

/* adds an item into a menu. */
Widget make_menu_item(char* item_name, caddr_t client_data, Widget
menu)
{
int ac;
Arg al[10];
Widget item;

ac = 0;
XtSetArg(al[ac], XmNlabelString, XmStringCreateLtoR(item_name,
char_set)); ac++;
item = XmCreatePushButton(menu, item_name, al, ac);
XtManageChild(item);
XtAddCallback(item, XmNactivateCallback, (void (*)(Widget, void*,
void*))menuCB, client_data);
XtSetSensitive(item, True);
return(item);
}

/* creates a menu on the menu bar */
Widget make_menu(char* menu_name, Widget menu_bar)
{
int ac;
Arg al[10];
Widget menu, cascade;

menu = XmCreatePulldownMenu(menu_bar, menu_name, NULL, 0);
ac = 0;
XtSetArg(al[ac], XmNsubMenuId, menu); ac++;
XtSetArg(al[ac], XmNlabelString, XmStringCreateLtoR(menu_name,
char_set)); ac++;
cascade = XmCreateCascadeButton(menu_bar, menu_name, al, ac);
XtManageChild(cascade);
return(menu);
}

/* creates all the menus for this program */
void create_menus(Widget menu_bar)
{
/* create the file menu */
file_menu = make_menu("File", menu_bar);
open_item = make_menu_item("Open", "Open", file_menu);
quit_item = make_menu_item("Quit", "Quit", file_menu);
}

int main(int argc, char* argv[])
{
Arg al[10];
int ac;

printf(TRIGGER_HANG);

/* create the toplevel shell */
toplevel = XtAppInitialize(&context, "" , NULL, 0, &argc, argv,
NULL, NULL, 0);

/* create a form widget */
ac = 0;
form = XmCreateForm(toplevel, "form", al, ac);
XtManageChild(form);

/* create the menu bar */
ac = 0;
menu_bar = XmCreateMenuBar(form, "menu_bar", al, ac);
XtManageChild(menu_bar);

/* attach the menu bar to the form */
ac = 0;
XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
XtSetValues(menu_bar, al, ac);

create_menus(menu_bar);

/* create a button */
ac = 0;
click = XmCreatePushButton(form, "Click", al, ac);
XtManageChild(click);

/* attach the button to the form */
ac = 0;
XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
XtSetArg(al[ac], XmNtopWidget, menu_bar); ac++;
XtSetValues(click, al, ac);

XtRealizeWidget(toplevel);
XtAppMainLoop(context);

return 0;
}
Reply With Quote
  #2  
Old 08-30-2008, 04:30 PM
Default Re: Menu usage hangs application

stefan.folkesson@gmail.com wrote:

>
> I have recreated my problem just by using a modified textbook motif
> example (attached below). The app has one toolbar button "click" and
> one menu "File". You get the deadlock by
> 1. Choose File->Open to start a sleep.
> 2. During the sleep, click twice on the menu "File". When the sleep
> completes, we will have the "north-east" mouse cursor.
> 3. Click the button "Click"
> and the system is locked
>


I can recreate it with openmotif-2.3 and Linux. It freezes the mouse
but the keyboard is still accessible and the program exits when sent
a kill signal 15.

>
> I'm hoping that one of you can tell me what's going on here, or even
> better, how to solve it
>


Do you think it is this bug:

http://bugs.motifzone.net/long_list.cgi?buglist=1412
Reply With Quote
  #3  
Old 08-31-2008, 04:32 PM
Default Re: Menu usage hangs application

Chris Sorenson wrote:
> Do you think it is this bug:
>
> http://bugs.motifzone.net/long_list.cgi?buglist=1412


It could also be this one:

http://bugs.motifzone.net/long_list.cgi?buglist=1328
and it was fixed three days ago.
http://openmotif.cvs.sourceforge.net...=date&view=log
Try it with the latest OpenMotif 2.3 CVS to see if it goes away.

Best regards,

DuĊĦan Peterc
http://www.arahne.si
Reply With Quote
Reply

Thread Tools


All times are GMT -5. The time now is 01:33 AM.

In an effort to better serve ads to our visitors, cookies are used on Fixunix.com. For more information, check out our Privacy Policy.

Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Ad Management by RedTyger