Form Unloaded But Not Deleted Exception

Forums for specific tips, techniques and example code
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Form Unloaded But Not Deleted Exception

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:20 pm

by Alistair Mackay >> Wed, 5 Jan 2000 1:38:56 GMT

Using the following code:

// check if a copy of form is already running
form := app.getForm(formClass.name).FwForm;

if form = null then
form := formClass.createInstance(true).FwForm;
form.setFormDefinition(fdef);
endif;
form.show;

I have got a 14037 : The form was previously unloaded exception.

How can I handle this situation where the getForm method returns a form which has been unloaded but not deleted, and an exception is raised when I try to show it.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Form Unloaded But Not Deleted Exception

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:20 pm

by Torrie Moore >> Wed, 5 Jan 2000 6:22:50 GMT

We have struck something similar which may shed light on your problem. If the form (FmFirst) is opened with a call to showModal, then any forms opened after FmFirst are not deleted until FmFirst is closed. Jade waits for a "quite point" before deleting forms. This may be what is causing your problem. We noticed this as the resources used did not drop when we closed modal forms.

I'm not sure how to detect that the form has been unloaded?

Torrie Moore
Concept Engineering Ltd.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Form Unloaded But Not Deleted Exception

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:20 pm

by Frank Pitt >> Mon, 31 Jan 2000 21:18:54 GMT

By not trying to show a form that has been unloaded.
<grin>

If all you want to do is reuse the instance of a running form use app.isFormOpen() instead

In general, keeping a reference to a form like this does _not_ guarantee that the form is still running as the code implies it is intended to do.

This can only be guaranteed to work if you _explicictly_ null the reference in the app instance in the unload method of your form, and of course, to do this with your call to get form, you'd need to be able to remove the form from the app objects collection !
It's easier and safer to have your own app reference to the window if you want to do this sort of thing.

BTW, it also sounds like you think you can unload a form and then re-show it.

Sorry, but you can't do that. You can call the unload() method safely, but that won't hide the form, calling unloadForm() _will_ result in the form being deleted (it's the equivalent of tthe user pressing the close button) as will calling showModally (as that automatically deletes calls unloadForm).

If you want to cache windows you need to prevent unloadForm on close button by overloading queryUnloadForm, preventing the close and instead setting the visible property on the form. Also do this wherever you'd normally call unloadForm in response to a user event.

Unfortunately you can't set the visible property on MDI children, so effecti vely the only forms you can safely cache are non-Modal, non-MDI forms.


_____________________________________
Frank Pitt
Mentor / Consultant
Software Education Associates Ltd
Cnr The Esplanade & Nevis St, Petone
Wellington New Zealand
Voice +64 4 568 7806 Fax +64 4 568 7920
Email frankp@softed.com
Web http://www.softed.com


Return to “Tips and Techniques”

Who is online

Users browsing this forum: No registered users and 7 guests