View Issue Details

IDProjectCategoryView StatusLast Update
0038512LazarusLCLpublic2021-02-23 13:43
ReporterDragisa Maksimovic Assigned ToBart Broersma  
Status resolvedResolutionno change required 
Product Version2.0.10 
Summary0038512: TStringGrid.Clean function does not clean objects only strings
DescriptionTStringGrid.Clean cleans grid cells of text, not underlying objects.....
Either a line like " Objects[ aCol, aRow ]:= nil ; should be added to the function

 for aCol:=StartCol to EndCol do
    for aRow:= StartRow to EndRow do
      if (CleanOptions=[]) or (CellToGridZone(aCol,aRow) in CleanOptions) then
        Cells[aCol,aRow] := TStringHelper.Empty ;
        Objects[ aCol, aRow ] := nil ;
      end ;

or additional function to clean objects should be introduced.....
TagsNo tags attached.
Fixed in Revision
Attached Files


Bart Broersma

2021-02-19 12:53

developer   ~0129016

Off Topic: since when is TStringHelper.Empty better then either EmptyStr (which IIRC is defined somewhere) or simply '' ?

Bart Broersma

2021-02-19 12:55

developer   ~0129017

Simply setting Objects to nil may introduce memory leaks in the program?

Bart Broersma

2021-02-19 16:00

developer   ~0129019

Last edited: 2021-02-19 16:06

View 2 revisions

It states that Objects will not be freed (and most likely not be nilled) even when the grid is destroyed.
OTOH Delphi's StringGrid does not implement a Clean method...

I think a separate CleanObjects would be the best option.
Or yet another default paramater to all the Clean() methods...
The Girds unit however is becoming a bit overcrowded with methods IMO.

Juha Manninen

2021-02-21 09:39

developer   ~0129049

Assigned to Bart. Please solve as you prefer.

Bart Broersma

2021-02-23 13:43

developer   ~0129121

I decided not to add functions like that to the grids unit.
While trivial to implement, it's triviality in itself makes this bloat in an already overcrowded grid.pas unit.
Also there remaisn the question: what does "clean" mean w.r.t an object: set it to nil, free it, free and nil it?
This should be left to the individual programmer.

Please close.

Issue History

Date Modified Username Field Change
2021-02-19 06:14 Dragisa Maksimovic New Issue
2021-02-19 12:53 Bart Broersma Note Added: 0129016
2021-02-19 12:55 Bart Broersma Note Added: 0129017
2021-02-19 16:00 Bart Broersma Note Added: 0129019
2021-02-19 16:06 Bart Broersma Note Edited: 0129019 View Revisions
2021-02-21 09:39 Juha Manninen Assigned To => Bart Broersma
2021-02-21 09:39 Juha Manninen Status new => assigned
2021-02-21 09:39 Juha Manninen Note Added: 0129049
2021-02-23 13:43 Bart Broersma Status assigned => resolved
2021-02-23 13:43 Bart Broersma Resolution open => no change required
2021-02-23 13:43 Bart Broersma LazTarget => -
2021-02-23 13:43 Bart Broersma Note Added: 0129121