While testing issue
https://bugs.freepascal.org/view.php?id=37216 I fell on TControl.WSRegisterClass and TWinControl.WSRegisterClass that are called repeatedly via TLCLComponent.NewInstance when creating a TLCLComponent descendant instance.
Taking a TControl as TLCLComponent descendant, is there a reason to not mark the class as registered the first time TControl.WSRegisterClass is called ?
Using RegisterControl (in \lcl\widgetset\wscontrols.pp) as a model, I apparently successfully managed to skip lots of code repetition at runtime, specifically the repeated calls to RegisterPropertyToSkip that need list scanning every time a NewInstance is created.
The code I have now for TControl and TWinControl WSRegisterClass are the following ones :
class procedure TControl.WSRegisterClass;
const
Registered : boolean = False;
begin
if Registered then
Exit;
inherited WSRegisterClass;
RegisterControl;
RegisterPropertyToSkip(TControl, 'AlignWithMargins', 'VCL compatibility property', '');
RegisterPropertyToSkip(TControl, 'Ctl3D', 'VCL compatibility property', '');
RegisterPropertyToSkip(TControl, 'ParentCtl3D', 'VCL compatibility property', '');
RegisterPropertyToSkip(TControl, 'IsControl', 'VCL compatibility property', '');
RegisterPropertyToSkip(TControl, 'DesignSize', 'VCL compatibility property', '');
RegisterPropertyToSkip(TControl, 'ExplicitLeft', 'VCL compatibility property', '');
RegisterPropertyToSkip(TControl, 'ExplicitHeight', 'VCL compatibility property', '');
RegisterPropertyToSkip(TControl, 'ExplicitTop', 'VCL compatibility property', '');
RegisterPropertyToSkip(TControl, 'ExplicitWidth', 'VCL compatibility property', '');
Registered := True;
end;
class procedure TWinControl.WSRegisterClass;
const
Registered : boolean = False;
begin
if Registered then
Exit;
inherited WSRegisterClass;
RegisterWinControl;
RegisterPropertyToSkip(TWinControl, 'ParentDoubleBuffered', 'VCL compatibility property', '');
RegisterPropertyToSkip(TWinControl, 'ImeMode', 'VCL compatibility property', '');
RegisterPropertyToSkip(TWinControl, 'ImeName', 'VCL compatibility property', '');
Registered := True;
end;
I rebuild lazarus and every thing works correctly.
Is there an obvious reason that it would create troubles ?
Lazarus quite recent trunk (+/- changes regarding TScrollBar, IntitalSetupDialog, Options.Environment options). FPC 3.0.4 (the mac os one) from svn + some mods.
Windows 10 Pro x64 (v. 1903 / 18362.418) and for occasional Linux tests, Manjaro (QT5 and GTK2)