Atozed Forums
Clear datas when switch forms - Printable Version

+- Atozed Forums (https://www.atozed.com/forums)
+-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html)
+--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html)
+---- Forum: English (https://www.atozed.com/forums/forum-16.html)
+----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html)
+----- Thread: Clear datas when switch forms (/thread-2286.html)



Clear datas when switch forms - matija - 02-15-2021

I have UIWServerControllerBaseConfig define two forms:

IWExceptionRenderer.SetExceptionRendererClass(TIWExceptionRendererEx);
 if FLock<>nil then FreeAndNil(FLock);
 FLock:= TCriticalSection.Create;
THandlers.Add('', 'Form1', TContentForm.Create(TForm1)); http://localhost/form1 (first load)
THandlers.Add('', 'Form2', TContentForm.Create(TForm2)); http://localhost/form2



In UserSesssion i have define procedures LoadDatas/ClearDatas with my TDatas. Both Forms used this procedures.

If switch Form2 then i want ClearDatas in Form1? If i dont, i get memory leaks from Form1, if destroy Usersession! Who Release!


RE: Clear datas when switch forms - Alexandre Machado - 02-16-2021

Each form should be responsible for its own clean up. That's what encapsulation means in OOP.

Clear the data when the form is destroyed and you won't get any leak.


RE: Clear datas when switch forms - Alexandre Machado - 02-16-2021

BTW, seems that you are creating a TCriticalSection in your ServerController... Not sure if it is related to the handlers or not, but content handlers don't need it.


RE: Clear datas when switch forms - matija - 02-17-2021

(02-16-2021, 07:02 PM)Alexandre Machado Wrote: BTW, seems that you are creating a TCriticalSection in your ServerController... Not sure if it is related to the handlers or not, but content handlers don't need it.

Shows this is cause for my memory leaks:

!!! TIWAppForm(WebApplication.ActiveForm).Release; !!! 
WebApplication.SetActiveForm(TLogOut.Create(WebApplication));

This line removed!Ok


RE: Clear datas when switch forms - matija - 02-17-2021

(02-16-2021, 07:02 PM)Alexandre Machado Wrote: BTW, seems that you are creating a TCriticalSection in your ServerController... Not sure if it is related to the handlers or not, but content handlers don't need it.

You cann see solution memory leaks!

I woudl like, when i leave page http://localhost/form1 -> http://localhost/form2 -> cleardatas in form1

Not when if usersession.destroy -> form1.destroy? In VCL Forms is this OnClose event? Recipe? Smile