View Issue Details

IDProjectCategoryView StatusLast Update
0030209LazarusLCLpublic2016-06-01 08:13
ReporterZoran VučenovićAssigned ToOndrej Pokorny 
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Product Version1.7 (SVN)Product Build 
Target VersionFixed in Version1.7 (SVN) 
Summary0030209: TGridColumn .Tag and TListColumn.Tag should be declared as PtrInt, not Integer
DescriptionTListColumn.Tag (unit ComCtrls) and TGridColumn.Tag (unit Grids) properties are declared as Integer.

Unlike these two, TComponent.Tag is PtrInt. I believe that these should also be PtrInt.

Then, Tag will be able contain pointers and objects. Now, when it is Integer (which is always 32-bit), it can't hold memory addresses on 64-bit.
Additional InformationI'm attaching the patch.
TagsNo tags attached.
Fixed in Revision52413,52414
LazTarget-
Widgetset
Attached Files
  • tag.patch (2,059 bytes)
    Index: lcl/comctrls.pp
    ===================================================================
    --- lcl/comctrls.pp	(revision 52408)
    +++ lcl/comctrls.pp	(working copy)
    @@ -1178,7 +1178,7 @@
         FVisible: Boolean;
         FWidth: TWidth;
         FImageIndex: TImageIndex;
    -    FTag: Integer;
    +    FTag: PtrInt;
         function GetWidth: TWidth;
         procedure WSCreateColumn;
         procedure WSDestroyColumn;
    @@ -1208,7 +1208,7 @@
         property ImageIndex: TImageIndex read FImageIndex write SetImageIndex default -1;
         property MaxWidth: TWidth read FMaxWidth write SetMaxWidth default 0;
         property MinWidth: TWidth read FMinWidth write SetMinWidth default 0;
    -    property Tag: Integer read FTag write FTag default 0;
    +    property Tag: PtrInt read FTag write FTag default 0;
         property Visible: Boolean read FVisible write SetVisible default true;
         property Width: TWidth read GetWidth write SetWidth default 50;
       end;
    Index: lcl/grids.pas
    ===================================================================
    --- lcl/grids.pas	(revision 52408)
    +++ lcl/grids.pas	(working copy)
    @@ -488,7 +488,7 @@
         FPickList: TStrings;
         FMinSize, FMaxSize, FSizePriority: ^Integer;
         FValueChecked,FValueUnchecked: PChar;
    -    FTag: Integer;
    +    FTag: PtrInt;
         procedure FontChanged(Sender: TObject);
         function GetAlignment: TAlignment;
         function GetColor: TColor;
    @@ -577,7 +577,7 @@
         property PickList: TStrings read GetPickList write SetPickList;
         property ReadOnly: Boolean read GetReadOnly write SetReadOnly stored IsReadOnlyStored;
         property SizePriority: Integer read GetSizePriority write SetSizePriority stored IsSizePriorityStored default 1;
    -    property Tag: Integer read FTag write FTag default 0;
    +    property Tag: PtrInt read FTag write FTag default 0;
         property Title: TGridColumnTitle read FTitle write SetTitle;
         property Width: Integer read GetWidth write SetWidth stored IsWidthStored default DEFCOLWIDTH;
         property Visible: Boolean read GetVisible write SetVisible stored IsVisibleStored default true;
    
    tag.patch (2,059 bytes)

Activities

Zoran Vučenović

2016-05-30 11:37

developer  

tag.patch (2,059 bytes)
Index: lcl/comctrls.pp
===================================================================
--- lcl/comctrls.pp	(revision 52408)
+++ lcl/comctrls.pp	(working copy)
@@ -1178,7 +1178,7 @@
     FVisible: Boolean;
     FWidth: TWidth;
     FImageIndex: TImageIndex;
-    FTag: Integer;
+    FTag: PtrInt;
     function GetWidth: TWidth;
     procedure WSCreateColumn;
     procedure WSDestroyColumn;
@@ -1208,7 +1208,7 @@
     property ImageIndex: TImageIndex read FImageIndex write SetImageIndex default -1;
     property MaxWidth: TWidth read FMaxWidth write SetMaxWidth default 0;
     property MinWidth: TWidth read FMinWidth write SetMinWidth default 0;
-    property Tag: Integer read FTag write FTag default 0;
+    property Tag: PtrInt read FTag write FTag default 0;
     property Visible: Boolean read FVisible write SetVisible default true;
     property Width: TWidth read GetWidth write SetWidth default 50;
   end;
Index: lcl/grids.pas
===================================================================
--- lcl/grids.pas	(revision 52408)
+++ lcl/grids.pas	(working copy)
@@ -488,7 +488,7 @@
     FPickList: TStrings;
     FMinSize, FMaxSize, FSizePriority: ^Integer;
     FValueChecked,FValueUnchecked: PChar;
-    FTag: Integer;
+    FTag: PtrInt;
     procedure FontChanged(Sender: TObject);
     function GetAlignment: TAlignment;
     function GetColor: TColor;
@@ -577,7 +577,7 @@
     property PickList: TStrings read GetPickList write SetPickList;
     property ReadOnly: Boolean read GetReadOnly write SetReadOnly stored IsReadOnlyStored;
     property SizePriority: Integer read GetSizePriority write SetSizePriority stored IsSizePriorityStored default 1;
-    property Tag: Integer read FTag write FTag default 0;
+    property Tag: PtrInt read FTag write FTag default 0;
     property Title: TGridColumnTitle read FTitle write SetTitle;
     property Width: Integer read GetWidth write SetWidth stored IsWidthStored default DEFCOLWIDTH;
     property Visible: Boolean read GetVisible write SetVisible stored IsVisibleStored default true;
tag.patch (2,059 bytes)

Vincent Snijders

2016-05-30 12:42

manager   ~0092898

What happens if a stream (e.g. from resource) created with an old lazarus version is read with a new lcl?

Zoran Vučenović

2016-05-30 13:55

developer   ~0092901

Last edited: 2016-05-30 14:00

View 3 revisions

@Vincent:
Please see FPC revision 16395 (http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/rtl/objpas/classes/classesh.inc?r1=16395&r2=16408)

That was the revision which just changed TComponent.Tag from LongInt to PtrInt.
Did we have any problems with component streaming then? Note that all LCL controls inherit this property from TComponent.

I have just loaded a project with TGridColumns, now with this patch applied in LCL. The project was created before, of course. I didn't see any problem.

Ondrej Pokorny

2016-05-30 18:19

reporter   ~0092907

As far as I understand, TReader checks the integer type from the file, so there shouldn't be any problem. See TReader.ReadInt64, TReader.ReadInteger.

Ondrej Pokorny

2016-05-30 23:12

reporter   ~0092912

Thank you!

Zoran Vučenović

2016-06-01 08:13

developer   ~0092935

Thank you, Ondrej, I'm closing it.

Issue History

Date Modified Username Field Change
2016-05-30 11:37 Zoran Vučenović New Issue
2016-05-30 11:37 Zoran Vučenović File Added: tag.patch
2016-05-30 12:42 Vincent Snijders Note Added: 0092898
2016-05-30 13:55 Zoran Vučenović Note Added: 0092901
2016-05-30 13:59 Zoran Vučenović Note Edited: 0092901 View Revisions
2016-05-30 14:00 Zoran Vučenović Note Edited: 0092901 View Revisions
2016-05-30 18:15 Ondrej Pokorny Status new => acknowledged
2016-05-30 18:19 Ondrej Pokorny Note Added: 0092907
2016-05-30 20:25 Ondrej Pokorny Assigned To => Ondrej Pokorny
2016-05-30 20:25 Ondrej Pokorny Status acknowledged => assigned
2016-05-30 23:12 Ondrej Pokorny Fixed in Revision => 52413,52414
2016-05-30 23:12 Ondrej Pokorny Note Added: 0092912
2016-05-30 23:12 Ondrej Pokorny Status assigned => resolved
2016-05-30 23:12 Ondrej Pokorny Resolution open => fixed
2016-06-01 08:13 Zoran Vučenović Note Added: 0092935
2016-06-01 08:13 Zoran Vučenović Status resolved => closed
2016-06-01 08:13 Zoran Vučenović Fixed in Version => 1.7 (SVN)