Form.Release + NIL

后端 未结 5 1288
无人及你
无人及你 2021-02-05 21:24

if Form.Release is called after using the form, it will free all related memory but not set the form variable to nil.

if not assigned (Form1) then
  begin
    Ap         


        
5条回答
  •  情话喂你
    2021-02-05 21:46

    Put the line

      Form1 := nil;  
    

    just after the call to Release.

    Release is just posting a CM_RELEASE message to the Form which allows the Form to finish what's in its queue (event handlers) before handling the CM_RELEASE message which means normally just calling Free.
    So, after calling Release, you should not assume that the Form variable still points to a valid Form, thus putting nil into the variable.

提交回复
热议问题