Sign in Join
Wiki copytemporary

User Changes 2.2.4: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: User Changes 2.2.4

OldNewLine
1+## About this page
2+
3+Below you can find a list of intentional changes between the [[User Changes 2.2.2|the 2.2.2 release]] and the 2.2.4 release which can change the behaviour of previously working code, along with why these changes were performed and how you can adapt your code if you are affected by them.
4+
5+## All systems
6+
7+### Default property values
8+
9+- **Old behaviour**: Published properties without a specified *default* were not streamed under certain circumstances.
10+- **New behaviour**: Such properties are now treated as if they had *nodefault* specified. This means that some extra properties will now be streamed in such cases:
11+ - Boolean fields with the value *false*
12+ - Enumerated types with the ordinal value *0*
13+- **Example**:
14+
15+``` pascal
16+type
17+ tenum = (ea,eb,ec);
18+ tc = class
19+ private
20+ fmybool: boolean;
21+ fenum: tenum;
22+ published
23+ property mybool: boolean read fmybool write fmybool;
24+ property enum: tenum read fenum write fenum;
25+ end;
26+
27+var
28+ c: tc;
29+begin
30+ c:=tc.create;
31+ // write c to a stream
32+end.
33+```
34+
35+In earlier versions, *mybool* nor *enum* would be written to the stream in this case, while now they will be.
36+
37+- **Reason**: Delphi compatibility.
38+- **Remedy**: Explicitly specify default values as follows
39+
40+``` pascal
41+type
42+ tenum = (ea,eb,ec);
43+ tc = class
44+ private
45+ fmybool: boolean;
46+ fenum: tenum;
47+ published
48+ property mybool: boolean read fmybool write fmybool default false;
49+ property enum: tenum read fenum write fenum default ea;
50+ end;
51+```
52+
53+### db unit: TField*.*Size type
54+
55+- **Old behaviour**: TFieldDef.Size, TField.Size and TField.DataSize were defined as word.
56+- **New behaviour**: TFieldDef.Size, TField.Size and TField.DataSize are defined as integers. This also means that definition of the corresponding methods has changed.
57+- **Example**: The following definitions of methods have been changed:
58+ - constructor TFieldDef.Create(AOwner: TFieldDefs; const AName: string; ADataType: TFieldType; ASize: **Integer**; ARequired: Boolean; AFieldNo: Longint)
59+ - procedure TFieldDef.SetSize(const AValue: **integer**);
60+ - function TField.GetDataSize: **integer**;
61+ - procedure TField.SetSize(AValue: **integer**);
62+- **Reason**: Delphi compatibility.
63+- **Remedy**: Change the definition of these properties in your methods that override one of the methods above from word to integer.
64+
65+### db unit: TField*.Lookup property is not published anymore
66+
67+- **Old behaviour**: TField.Lookup was published, so it was streamed if it was set to True (i.e. for a fkLookup field)
68+- **New behaviour**: TField.Lookup is not published anymore, so if you try to read back its streamed value (e.g., loading Lazarus forms) it will fail.
69+- **Reason**: The value of this property was also modified by setting FieldKind, which is also streamed. See [Bug 12809](http://bugs.freepascal.org/view.php?id=12809)
70+- **Remedy**: If you use Lazarus, remove references to *Lookup* properties in your project's lfm files.
71+
72+## All Unix-based systems
73+
74+### Executing external programs using TProcess
75+
76+- **Old behaviour**: When TProcess was used to execute a program and no explicit path to the executable was given, TProcess searched for the executable in the current directory, and only if it was not found there it looked in the system path.
77+- **New behaviour**: On all Unix-based systems, TProcess will not search for the executable in the current directory anymore, unless the current directory is in the system path.
78+- **Example**: When you use TProcess to execute 'ls' and there is an 'ls' executable in both the current directory and in '/bin/', then programs compiled with FPC 2.2.2 will execute './ls' (thus in the current directory). Programs compiled with FPC 2.2.4 will run '/bin/ls' instead.
79+- **Reason**: Security. Unix-users don't expect that files in the current directory are executed in favour of those in the system path.
80+- **Remedy**: If you really want to execute an executable in the current directory, use './exec-name' as executable name.
81+
82+## Non-x86 and non-linux/ppc64 systems
83+
84+### Floating point rounding
85+
86+- **Old behaviour**: On these platforms, the *round()* function always rounded to the nearest integer, halfway away from zero.
87+- **New behaviour**: By default, *round()* now performs *banker's rounding* (round-to-nearest, halfway to even). If the rounding mode is changed using the *Math* unit's *SetRoundMode()* function, the *round()* function now honours this change.
88+- **Example**:
89+
90+``` pascal
91+begin
92+ write(round(-2.5),' ');
93+ write(round(-1.5),' ');
94+ write(round(-0.5),' ');
95+ write(round(0.5),' ');
96+ write(round(1.5),' ');
97+ writeln(round(2.5));
98+end.
99+```
100+
101+The above program used to print:
102+
103+` -3 -2 -1 1 2 3`
104+
105+Now it will print:
106+
107+` -2 -2 0 0 2 2`
108+
109+- **Reason**: Compatibility with TP/Delphi.
110+- **Remedy**: If you want to use other kinds of rounding, you can change the rounding mode using *Math.SetRoundMode()*, or use John Herbster's unit attached to [bug report 12687](http://bugs.freepascal.org/view.php?id=12687).
111+
112+## Windows Platforms
113+
114+### Functions removed from the Windows unit
115+
116+- **Old behaviour**: The following functions were declared in the Windows unit (including *A* and *W* variants where applicable):
117+ - comdlg32.dll:
118+ - *ChooseColor*
119+ - *ChooseFont*
120+ - *CommDlgExtendedError*
121+ - *CreateStatusWindow*
122+ - *FindText*
123+ - *GetFileTitle*
124+ - *GetOpenFileName*
125+ - *GetSaveFileName*
126+ - *PageSetupDlg*
127+ - *PrintDlg*
128+ - *ReplaceText*
129+ - comctl32.dll (and some helper routines):
130+ - *CreateMappedBitmap*
131+ - *CreatePropertySheetPage*
132+ - *CreateToolbarEx*
133+ - *CreateUpDownControl*
134+ - *DrawInsert*
135+ - *DrawStatusText*
136+ - *GetEffectiveClientRect*
137+ - *ImageList_Add*
138+ - *ImageList_AddIcon*
139+ - *ImageList_AddMasked*
140+ - *ImageList_BeginDrag*
141+ - *ImageList_Create*
142+ - *ImageList_Destroy*
143+ - *ImageList_DragEnter*
144+ - *ImageList_DragLeave*
145+ - *ImageList_DragMove*
146+ - *ImageList_DragShowNolock*
147+ - *ImageList_Draw*
148+ - *ImageList_DrawEx*
149+ - *ImageList_EndDrag*
150+ - *ImageList_GetBkColor*
151+ - *ImageList_GetDragImage*
152+ - *ImageList_GetIcon*
153+ - *ImageList_GetIconSize*
154+ - *ImageList_GetImageCount*
155+ - *ImageList_GetImageInfo*
156+ - *ImageList_LoadImage*
157+ - *ImageList_Merge*
158+ - *ImageList_Remove*
159+ - *ImageList_Replace*
160+ - *ImageList_ReplaceIcon*
161+ - *ImageList_SetBkColor*
162+ - *ImageList_SetDragCursorImage*
163+ - *ImageList_SetIconSize*
164+ - *ImageList_SetImageCount*
165+ - *ImageList_SetOverlayImage*
166+ - *LBItemFromPt*
167+ - *MakeDragList*
168+ - *MenuHelp*
169+ - *PropertySheet*
170+ - *ShowHideMenuCtl*
171+- **New behaviour**: These function have been removed from the Windows unit.
172+- **Reason**: Delphi compatibility, remove definitions of functions also declared in the *commdlg* and *commctrl* units.
173+- **Remedy**: Add the *commdlg* and/or *commctrl* unit(s) to your uses clause.
174+
175+---
176+*From the Free Pascal wiki, page "User Changes 2.2.4", as it stood on 2020-03-03 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
177+Category: FPC User Changes by release
178+Category: Release Notes

Back to history