Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Freeing form variable
#1
Question 
Hello,
in a IW form I create a TObjectList<T> in my CreateAndInit constructor.
The constructor call the inherited Create(AOwner) as its first instruction.
In the OnDestroy method I am freeing the TObjectList<T> calling TObjectList<T>.Free.
When I move from this form to another I call TIWAppForm(WebApplication.ActiveForm).Release and the destructor is executed in the right way.

The problem raises when I close the application cause it is shown an AV error which is not shown if I remove the freeing of the TObjectList<T> in the Destructor.

It seems the form is released another time when the application closes.

Any advice about  how to remove my form variable avoiding the AV error when the application closes?

Thank you,
Davide
Reply
#2
Something doesn't look correct in this scenario. What's your IW version?

TIWAppForm(WebApplication.ActiveForm).Release won't call the destructor of the form immediately, only after the whole response has been generated. It would be good to know exactly if somehow in your case the destructor is called *immediately* after the call to Release (and no other code runs in between).

Also where exactly is TIWAppForm(WebApplication.ActiveForm).Release in relation to the code that creates and shows a new form?

Why don't you try to use what IW has built-in, instead of writing lots of code yourself?

You can simply call:

WebApplication.ShowForm(TIWForm1, True, True);

The first parameter is the class of the form

The second is a flag indicating if the Active form must be released afterwards (exactly what you want)

The third is another flag indicating if any existing TIWForm1 instance can be used instead of creating a new one (in most cases, True is the adequate choice)
Reply
#3
(05-27-2022, 12:48 AM)Hi Alexandre,my IW version is 15.2.54 and I my delphi version is 11.1Following the code in my MoveToForm procedure:  TIWAppForm(WebApplication.ActiveForm).Release; Wrote:   var

    CartForm: TCartForm := TCartForm.CreateAndInit(WebApplication, FOrder);
  CartForm.Show;

I have no knowledge about the existence of WebApplication.ShowForm procedure, where is it documented ?

I create a form constructor to accept an object that will be managed inside the form so I don't believe I can show the form via the ShowForm procedure but if I can suggest me how.

Thank you for your support,
Davide


Alexandre MachadoSomething doesn't look correct in this scenario. What's your IW version?

TIWAppForm(WebApplication.ActiveForm).Release won't call the destructor of the form immediately, only after the whole response has been generated. It would be good to know exactly if somehow in your case the destructor is called *immediately* after the call to Release (and no other code runs in between).

Also where exactly is TIWAppForm(WebApplication.ActiveForm).Release in relation to the code that creates and shows a new form?

Why don't you try to use what IW has built-in, instead of writing lots of code yourself?

You can simply call:

WebApplication.ShowForm(TIWForm1, True, True);

The first parameter is the class of the form

The second is a flag indicating if the Active form must be released afterwards (exactly what you want)

The third is another flag indicating if any existing TIWForm1 instance can be used instead of creating a new one (in most cases, True is the adequate choice)
Reply
#4
(05-27-2022, 12:48 AM)Alexandre Machado Wrote: Something doesn't look correct in this scenario. What's your IW version?

TIWAppForm(WebApplication.ActiveForm).Release won't call the destructor of the form immediately, only after the whole response has been generated. It would be good to know exactly if somehow in your case the destructor is called *immediately* after the call to Release (and no other code runs in between).

Also where exactly is TIWAppForm(WebApplication.ActiveForm).Release in relation to the code that creates and shows a new form?

Why don't you try to use what IW has built-in, instead of writing lots of code yourself?

You can simply call:

WebApplication.ShowForm(TIWForm1, True, True);

The first parameter is the class of the form

The second is a flag indicating if the Active form must be released afterwards (exactly what you want)

The third is another flag indicating if any existing TIWForm1 instance can be used instead of creating a new one (in most cases, True is the adequate choice)


Hi Alexandre,

I found the error that is not related to any IW form management but It was my error releasing an item of a list owned by the form I was releasing.
Thak you for your support and if you have time send me some advice about what I ask to you in my previous reply.

Greetings,
Davide
Reply
#5
Hi David,

the IWApplication class doc can be found here: http://docs.atozed.com/Docs.dll/classes/...ation.html

Cheers
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)