I have a form which includes a field.  The field accepts categories and
subcategories, separated by colons.  When the program detects a focus
change, the user's input is checked, and if any single part is longer than
32 characters, a FrmAlert is displayed.

The form also includes a button which, when tapped, pops up a list.

Here's my problem:

If the user enters more than 32 characters, then taps on the button, the
Alert is displayed.  Then the popup list is displayed (using LstPopupList).
If the user then taps on the button again, the list is dismissed (with -1
selected).

Now, ... bear with me ... if the user types ctrl-A (the menu shortcut) the
menu is displayed.  Choosing a menu item causes a crash, with "(program) has
just read from an unallocated chunk of memory."

I put a breakpoint in the main event loop and found this:

Tapping the button generates:
        penDownEvent
        ctlEnterEvent
        ctlSelectEvent

In ctlSelectEvent, my code first does validation of the previous focus
field, and in this case pops up an alert about the 32 character limit.

The user taps OK in the alert and the list pops up (via LstPopupList in the
ctlSelectEvent processing).

Tapping the button again causes no event in the main loop, because
LstPopupList has its own event loop.  The next event to show up in the main
loop is:

        winExitEvent (x=-37,y=65) enterWindow=0, exitWindow=0x00018D10
        penUpEvent (x=77,y=112)

Now, ctrl-A to launch the menu
        keyDownEvent (chr=0x105)
        winEnterEvent enterWindow=0x00018CE0, exitWindow=0x00018D10

Menu is now showing... select a menu item...
        penDownEvent (x=75,y=49)
        winExitEvent enterEvent=0x00018D10, exitWindow=0x00018CE0
        winEnterEvent enterEvent=0x00018D10, exitWindow=0x00018CE0

It appears that window 0x00018D10 is the popup list, which has already been
dismissed and destroyed.  In the next call to EvtGetEvent, it attempts to
access this window (which of course is now the DrawWindow) and crashes.

I suspect that what is happening is that the event loop in LstPopupList is
sucking up and losing some events generated by the FrmAlert dismissal, and
losing track of the active window.

I have completely fried my brain just tracking this problem down, and I have
no viable brain cells left to decide what to do about it.  I've had numerous
problems with popping up alerts and forms during field change and form close
processing... Is there a good, reliable way to validate fields?

All advice gratefully appreciated!

David Kendall
Ultra Software Systems, Ltd.
http://www.ultrasoft.com

Reply via email to