[Lazarus] Custom TStrings descendents

Michael Van Canneyt michael at freepascal.org
Fri Jan 11 11:54:27 CET 2019


Hi,

Please check the TStrings descendents in

lcl/interfaces/qt5/qtobjects.pas (Line 4763)
ide/inputhistory.pas (Line 676)
components/fpvectorial/docxvectorialwriter.pas (line 414)
lcl/interfaces/cocoa/cocoatextedits.pas (line 1146)

They are not calling the inherited constructor. 
As a result, LoadFromFile() will crash, since no default encoding is present.
(the default encoding is set in the constructor)

Unless you know what you are doing, you must always call the inherited constructor, 
if there is one. You must give the parent class the chance to initialize itself
correctly. It's not because a particular constructor is empty today, that it will be
empty tomorrow.

Michael.

PS. And yes, this requirement *is* Delphi compatible.



More information about the lazarus mailing list