Quitting standalone, is this a bug?
Devin Asay
devin_asay at byu.edu
Thu May 17 12:47:40 EDT 2007
Hi Michael. Welcome to the list.
On May 17, 2007, at 10:21 AM, Michael Binder wrote:
> Hi everyone,
>
> This is my first post to this list. I'm new to Rev (but much
> hypercard experience). I have just spent a couple of days figuring
> something out (it may be a bug) so I thought I'd share it. I am
> developing with Studio 2.81 and testing on an mac ibook G4 running
> 10.3.9.
>
> To demonstrate the bug:
> Step 1) create a new main stack and call it "myApp".
> Step 2) Put this handler into the stack script:
>
> on shutdownrequest
> answer "This stack: "& the name of this stack &cr& "Quit now?"
> with "Yes" or "No"
> if it is "Yes" then pass shutdownrequest
> end shutdownrequest
>
> Step 3) Save myApp, and then save it as a mac OS X standalone.
> Step 4) Launch the standalone.
> Step 5) Quit (by menu or commandkey Q) and choose "No". (the
> behavior is as expected)
> Step 6) Quit again. This time the bug is evident...
>
> On my system, the second (and all subsequent) quit brings up a
> dialog box with an unexpected result: This stack: stack "answer
> dialog"
This is probably more an unexpected result than a bug. The problem
seems to be caused by the nature of the message hierarchy. Every
window in Rev is a stack, including the answer dialog, and every time
you try to quit the Rev engine, a shutdownrequest will be sent to the
current stack. If it's not handled by that stack it'll pass up the
hierarchy until it finds a handler.
You might try this and see what happens:
answer "This stack: " & the mainstack of this stack & cr & "Quit
now?" etc.
You could also try putting one or more exceptions in your
shutdownrequest handler:
if the style of this stack is topLevel then -- would only execute
if the stack receiving the shutdownrequest was non-modal.
if the visible of this stack then -- would ensure shutdownrequest
would only be handled in a visible stack
Or a combination of the above.
>
> I discovered this bug in myBigComplexApp, and the bug there is a
> bit different. The first time I quit myBigComplexApp, "This stack"
> is "revExternalLibrary". On the second and all subsequent quits
> "this stack" is "answer dialog". (as in the example above)
>
> This is a problem for me because when a user quits myBigComplexApp
> I need to validate data and offer the user a chance to save the
> changes. In order to do this I need to determine what data entry
> card the user is viewing when the quit request occurs:
>
> on shutdownrequest -- this does not work as expected because of
> the bug
> if the short name of this cd is "dataEntry1" then
> validateData1
> else if the short name of this cd is "dataEntry2" then
> validateData2
> end if
> offerChanceToSave
> end shutdownrequest
>
> My workaround for the bug is as follows:
>
> on shutdownrequest
> put line 1 of the recentcards of stack "myBigComplexApp" into
> whichcard
> if the short name of whichcard is "dataEntry1" then
> validateData1
> else if the short name of whichcard is "dataEntry2" then
> validateData2
> end if
> offerChanceToSave
> end shutdownrequest
>
> I am not all that confident in my workaround because I am not
> confident that I understand the nature of the bug. As I mentioned
> above, the bug in (simple) myApp is a bit different than in
> myBigComplexApp.
>
> Do any of you have any thoughts on whether this is a bug, whether
> it occurs on other platforms, and whether my workaround could be
> improved?
Would it work to do data vaildation on closeStack instead of
shutdownrequest?
HTH
Devin
Devin Asay
Humanities Technology and Research Support Center
Brigham Young University
More information about the use-livecode
mailing list