I have a component containing an event property with a setter. When I install the component into the IDE, the property value disappears each time when I reload the project.
Consider the following source (example package and project attached):
unit Shape1;
{$mode ObjFPC}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, ExtCtrls;
type
{ TShape1 }
TShape1 = class(TShape)
private
FOnWhatever: TNotifyEvent;
procedure SetOnWhatever(AValue: TNotifyEvent);
public
procedure DoWhatever;
published
property OnWhatever: TNotifyEvent read FOnWhatever write SetOnWhatever;
end;
procedure Register;
implementation
procedure Register;
begin
{$I shape1_icon.lrs}
RegisterComponents('Misc',[TShape1]);
end;
{ TShape1 }
procedure TShape1.SetOnWhatever(AValue: TNotifyEvent);
begin
if FOnWhatever=AValue then Exit; // <--- Comment this, troubles the obj.inspector
FOnWhatever:=AValue;
end;
procedure TShape1.DoWhatever;
begin
if Assigned(FOnWhatever) then
FOnWhatever(Self);
end;
end.
The example project compiles and works as expected, i.e. the event property have the proper value, only it is lost into the object inspector.
When I comment line #38 above, the issue disappears.
Anyone have an idea?
Found this:
https://forum.lazarus.freepascal.org/index.php/topic,29609.0.html but no explanation there.
My Laz is rather old, but anyway: Lazarus 2.2.4 (rev lazarus_2_2_4) FPC 3.2.2 x86_64-linux-gtk2.