Difference between revisions of "User Changes 2.2.4"

From Lazarus wiki
Jump to navigationJump to search
Line 33: Line 33:
 
In earlier versions, ''mybool'' nor ''enum'' would be written to the stream in this case, while now they will be.
 
In earlier versions, ''mybool'' nor ''enum'' would be written to the stream in this case, while now they will be.
 
* '''Reason''': Delphi compatibility.
 
* '''Reason''': Delphi compatibility.
* '''Remedy''': Adapt your streaming code to take this change into account.
+
* '''Remedy''': Explicitly specify default values as follows
 +
<delphi>
 +
type
 +
  tenum = (ea,eb,ec);
 +
  tc = class
 +
  private
 +
    fmybool: boolean;
 +
    fenum: tenum;
 +
  published
 +
    property mybool: boolean read fmybool write fmybool default false;
 +
    property enum: tenum read fenum write fenum default ea;
 +
  end;
 +
</delphi>
  
 
=== db unit: TField.GetDataSize return type ===
 
=== db unit: TField.GetDataSize return type ===

Revision as of 18:32, 29 December 2008

About this page

Below you can find a list of intentional changes between the 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.

All systems

Default property values

  • Old behaviour: Published properties without a specified default were not streamed under certain circumstances.
  • 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:
    • Boolean fields with the value false
    • Enumerated types with the ordinal value 0
  • Example:

<delphi> type

 tenum = (ea,eb,ec);
 tc = class
  private
   fmybool: boolean;
   fenum: tenum;
  published
   property mybool: boolean read fmybool write fmybool;
   property enum: tenum read fenum write fenum;
 end;

var

 c: tc;

begin

 c:=tc.create;
 // write c to a stream

end. </delphi> In earlier versions, mybool nor enum would be written to the stream in this case, while now they will be.

  • Reason: Delphi compatibility.
  • Remedy: Explicitly specify default values as follows

<delphi> type

 tenum = (ea,eb,ec);
 tc = class
  private
   fmybool: boolean;
   fenum: tenum;
  published
   property mybool: boolean read fmybool write fmybool default false;
   property enum: tenum read fenum write fenum default ea;
 end;

</delphi>

db unit: TField.GetDataSize return type