[comp.windows.open-look] XView notify problem

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