Recent

Author Topic: [SOLVED] Modification of TCDEdit's destructor  (Read 2318 times)

lagprogramming

  • Sr. Member
  • ****
  • Posts: 407
[SOLVED] Modification of TCDEdit's destructor
« on: July 11, 2023, 11:21:14 am »
lcl/customdrawncontrols.pas has the following destructor:
Code: Pascal  [Select][+][-]
  1. destructor TCDEdit.Destroy;
  2. begin
  3.   inherited Destroy;
  4.   FLines.Free;
  5.   //FCaretTimer.Free; Don't free here because it is assigned with a owner
  6. end;
inherited Destroy; is followed by a FLines.Free; line, where FLines is a TStringList.
The following patch modifies the destructor in order to free FLines before inherited Destroy;.
Code: Pascal  [Select][+][-]
  1. diff --git a/lcl/customdrawncontrols.pas b/lcl/customdrawncontrols.pas
  2. index d9b6bb2035..2b852abf5c 100644
  3. --- a/lcl/customdrawncontrols.pas
  4. +++ b/lcl/customdrawncontrols.pas
  5. @@ -2044,8 +2044,8 @@ end;
  6.  
  7.  destructor TCDEdit.Destroy;
  8.  begin
  9. -  inherited Destroy;
  10.    FLines.Free;
  11. +  inherited Destroy;
  12.    //FCaretTimer.Free; Don't free here because it is assigned with a owner
  13.  end;
« Last Edit: July 19, 2023, 12:09:47 pm by lagprogramming »

Zvoni

  • Hero Member
  • *****
  • Posts: 2818
Re: Modification of TCDEdit's destructor
« Reply #1 on: July 11, 2023, 11:28:57 am »
Interesting.
I was always under the impression, that Inherited Destroy; should always be called last in your own destructor  (meaning cleaning up your own mess before .... )
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad


 

TinyPortal © 2005-2018