hari@matrix.UUCP (T hariharan) (03/23/91)
We've been having a problem with handling XView notification. Setup: ------ We put up a popup with two panel items to prompt for a filename, as shown below: File: ___________________________________ ------ | Load | ------ The PANEL_NOTIFY_PROC's are the same for both the Load button and the Text item (the text items' PANEL_NOTIFY_STRING is "\n\r"). The notify procedure looks somewhat like this (should be easy to guess that it was generated by "guide"): void notify_proc(item, event) Panel_item item; Event *event; { evfile_popup_objects *file_ip = (evfile_popup_objects *) xv_get(item, XV_ KEY_DATA, INSTANCE); char *filename; filename = (char *) xv_get(file_ip->file_text, PANEL_VALUE); load_data(filename); if (xv_get(file_ip->popup, FRAME_CMD_PUSHPIN_IN) == FALSE) xv_destroy_safe(file_ip->popup); } The "evfile_popup_objects" struct is: typedef struct { Xv_opaque popup; Xv_opaque panel; Xv_opaque file_text; Xv_opaque button; } evfile_popup_objects; Problem: -------- If you enter a filename and hit <Return> twice in a row quickly, the program crashes. What happens is, after the first <Return>, the notify procedure gets called. After it returns, it gets called again, for the second <Return> ! During the second call, the program crashes when we check the FRAME_CMD_PUSHPIN_IN attribute. During the first call, the popup gets destroyed, so XView should not have any record of it. But it somehow figures out that the second <Return> also belongs to the already destroyed popup. This is possible if XView decides which window a keyboard event should be delivered to as soon as it receives it (as opposed to just putting the event on a queue and deciding later, when processing that event). What's interesting is that, if, instead of typing <Return> twice, you press the "Load" button twice in a row, the program does not crash. If you combine <Return> and Load, it crashes if the <Return> comes after ther Load, but not if it comes before. Given that XView works this way, can anyone suggest a nice workaround ? Please email your responses to me. I'll summarize. Thanks Hari uunet!matrix!hari Matrix Computer Systems, Inc. 7 1/2 Harris Road Nashua NH 03062 (603) 886-3872
rick@pbi.COM (Richard M. Goldstein) (03/26/91)
if (xv_get(file_ip->popup, FRAME_CMD_PUSHPIN_IN) == FALSE) xv_destroy_safe(file_ip->popup); Problem: -------- If you enter a filename and hit <Return> twice in a row quickly, the program crashes. What happens is, after the first <Return>, the notify procedure gets called. After it returns, it gets called again, for the second <Return> ! During the second call, the program crashes when we check the FRAME_CMD_PUSHPIN_IN attribute. "xv_destroy_safe()" is a *poorly* documented form of "xv_destroy()" that, i quess, waits until it gets around to it to destroy something (as opposed to destroying it immediately). my experince is that i get highly unpredictable results whenever i have tried to use it (just like you), and these problems go away as soon as i switch to xv_destroy(). Give it a try. rick %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % Richard M. Goldstein % % % % Perfect Byte, Inc. Phone: (402)554-1122 % % 7121 Cass St. Fax: (402)554-1938 % % Omaha, NE 68132 email: rick@pbi.com % % % % "If I knew what I was doing, % % d'ya think I'd be in Omaha?" % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%