View Issue Details

IDProjectCategoryView StatusLast Update
0009366LazarusDocumentationpublic2015-03-14 19:40
ReporterivansbAssigned ToBart Broersma 
PrioritynormalSeverityfeatureReproducibilityalways
Status resolvedResolutionfixed 
Product Version0.9.22Product Build 
Target Version1.4Fixed in Version1.4 
Summary0009366: TStrings implementation in combo objects - TObject not working
DescriptionTry some code like this...

procedure TfrmPrincipal.Memo1MouseDown(Sender: TOBject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  r:integer;
  umObjeto:TObject;
  umaLista:TStrings;
begin
  Memo1.Lines.clear;
  TStringList(Memo1.Lines).AddObject('13', TObject(13));
  Memo1.lines.add('-'+InttoStr(Integer(TStringList(Memo1.Lines).Objects[0])));
  TStringList(Memo1.Lines).Objects[0]:=TObject(14);
  Memo1.lines.add('-'+InttoStr(Integer(TStringList(Memo1.Lines).Objects[0])));
  umaLista:=TStringlist.create;
  umaLista.AddObject('15', TObject(15));
  Memo1.lines.add('--'+InttoStr(Integer(umaLista.objects[0])));
  umaLista.Objects[0]:=TObject(16);
  Memo1.lines.add('--'+InttoStr(Integer(umaLista.objects[0])));
end;

The result is
13
-0
-0
15
--15
--16
and not
13
-13
-14
15
--15
--16

as it should be.
TagsNo tags attached.
Fixed in Revisionr48347
LazTarget-
WidgetsetGTK
Attached Files

Activities

Mattias Gaertner

2007-08-01 23:49

manager   ~0013923

Note: Memo1.Lines is not always a TStringList. Especially in the above case it is not a TStringList. But TStrings has an AddObject method too, so the bug report ist correct.

I set the severity to minor, because TMemo edits text, not lines. For example the user can copy and paste a 'line' and the 'Object' will not be copied.
In other words: If you need 'Object' per line, either use a TListBox or you have to help TMemo to handle the Objects anyway.

Gerard V

2007-08-03 10:01

reporter   ~0013945

The behaviour seems to be consistent with Delphi 7 VCL, wich shows the same values in a TMemo, wich has also a TStrings, not a TStringList.

From the Delphi 7 help about TStrings:

"Setting the Objects property for TStrings does nothing. Reading the Objects property for TStrings returns nil (Delphi) or NULL (C++). Descendant classes can associate objects with the strings in the set by implementing the Objects property."

I would suggest to close the issue or reformulate it as a wish to have TMemo store its lines in a TStringList instead of a TStrings, if someone sees any utility in this.

Mattias Gaertner

2007-08-03 11:09

manager   ~0013946

Delphi 7 TMemo does not support Objects. We can change it to a feature request.

Georg Hieber

2013-08-26 01:14

reporter   ~0069529

Last edited: 2013-08-27 00:20

View 2 revisions

TStrings has an AddObject method which is declared virtual, not abstract, so some functionality is expected. Anyway, in a derived class the implementation of it's anchestor's abstract methods is expected, if this is not the case it should be documented.

I suggest to change severity back to some bug level, and either one day fix it, or enter a note into TMemo (or TCustomMemo)'s documentation saying "T(Custom)Memo does notsupport objects in it's lines property. While AddObject etc. appear to work, objects[] will always return NIL" or something similar.

After revising the TTextstring source, it is obvious why this is not implemented and why it would be difficult to do so. The suggestion therefore goes to changing TMemo's documentation.

Even a remark in TStrings' documentation might be considered, like "the lcl contains components with properties descendant from TStrings that do not implement all methods declared in TStrings."

Bart Broersma

2015-03-14 19:40

developer   ~0081963

Please close if OK.

Issue History

Date Modified Username Field Change
2007-08-01 23:02 ivansb New Issue
2007-08-01 23:02 ivansb Widgetset => GTK
2007-08-01 23:49 Mattias Gaertner LazTarget => -
2007-08-01 23:49 Mattias Gaertner Note Added: 0013923
2007-08-01 23:49 Mattias Gaertner Severity block => minor
2007-08-02 13:38 Vincent Snijders LazTarget - => 1.0
2007-08-02 13:39 Vincent Snijders Status new => acknowledged
2007-08-03 10:01 Gerard V Note Added: 0013945
2007-08-03 11:09 Mattias Gaertner Note Added: 0013946
2007-08-03 11:09 Mattias Gaertner LazTarget 1.0 => post 1.2
2007-08-03 11:09 Mattias Gaertner Severity minor => feature
2007-08-03 11:09 Mattias Gaertner Status acknowledged => confirmed
2013-08-26 01:14 Georg Hieber Note Added: 0069529
2013-08-27 00:20 Georg Hieber Note Edited: 0069529 View Revisions
2013-09-03 12:07 Martin Friebe LazTarget post 1.2 => 1.4
2014-09-10 20:58 Juha Manninen LazTarget 1.4 => -
2015-03-14 19:40 Bart Broersma Category LCL => Documentation
2015-03-14 19:40 Bart Broersma Fixed in Revision => r48347
2015-03-14 19:40 Bart Broersma Note Added: 0081963
2015-03-14 19:40 Bart Broersma Status confirmed => resolved
2015-03-14 19:40 Bart Broersma Fixed in Version => 1.4
2015-03-14 19:40 Bart Broersma Resolution open => fixed
2015-03-14 19:40 Bart Broersma Assigned To => Bart Broersma
2015-03-14 19:40 Bart Broersma Target Version => 1.4