Recent

Author Topic: published properties  (Read 5488 times)

JimKueneman

  • Full Member
  • ***
  • Posts: 220
published properties
« on: January 31, 2015, 07:34:24 pm »
I have some custom components I have created.  I have a few published events that use setters.  The events that use setters will not read back the events.  The event and handlers are in the *.lfm file but when I go back to the object inspector and reopen the form the events are disconnected from the handlers....

Jim

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: published properties
« Reply #1 on: January 31, 2015, 07:53:04 pm »
How did you override the DefineProperties procedure?

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Re: published properties
« Reply #2 on: January 31, 2015, 08:18:08 pm »
You should show us the code. Usually, events are defined like:
Code: [Select]
property OnChange: TNotifyEvent read FOnChange write FOnChange;If you use setter "SetOnChange", it should have code like:
Code: [Select]
  if FOnChange=AValue then exit;
  FOnChange:=AValue;
  ...your code...
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

JimKueneman

  • Full Member
  • ***
  • Posts: 220
Re: published properties
« Reply #3 on: January 31, 2015, 08:35:05 pm »
Code: [Select]
type
    TOnMessageEvent = procedure(Sender: TObject; OlcbMessage: TOlcbMessage) of object;

Code: [Select]
  TMustangpeakComConnection = class(TComponent) 
 private
    FOnSendMessage: TOnMessageEvent;
    procedure SetOnSendMessage(AValue: TOnMessageEvent);
published
    property OnSendMessage: TOnMessageEvent read FOnSendMessage write SetOnSendMessage;                     

Code: [Select]
procedure TMustangpeakComConnection.SetOnSendMessage(AValue: TOnMessageEvent);
begin
  if FOnSendMessage <> AValue then
  begin
    FOnSendMessage:=AValue;
    if not (csDesigning in ComponentState) then
      UpdateThreadsEvents;
  end;
end;

I have not overridden DefineProperty

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Re: published properties
« Reply #4 on: January 31, 2015, 08:59:56 pm »
I can't see anything wrong although I never used setters for events.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

Basile B.

  • Guest
Re: published properties
« Reply #5 on: February 01, 2015, 12:59:41 am »
Check/Verify you register procedure.

Code: [Select]
procedure Register;
begin
  RegisterComponents('MyCategory', [TMustangpeakComConnection]);
end;

and also

initialization
  RegisterClasses([TMustangpeakComConnection]);
end.

Have you changed the classes after having setup the component ?
Since the components are statically linked maybe you also have to reinstall (not just compile) your package after each modification.
« Last Edit: February 01, 2015, 02:17:29 pm by Basile B. »

JimKueneman

  • Full Member
  • ***
  • Posts: 220
Re: published properties
« Reply #6 on: February 01, 2015, 02:53:19 am »
Quote
Check/Verify you register procedure.

Code: [Select]
procedure Register;
begin
  RegisterComponents('MyCategory', [TMustangpeakComConnection]);
end;

and also

initialization
  RegisterClasses([TMustangpeakComConnection]);
end.

First one was already done.  The second did not change anything

Quote
Have you changed the classes after having setup the component ?
Since the components are statically linked maybe you also have to reinstall (not just compile) your package after each modification.

No effect.

Jim

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: published properties
« Reply #7 on: February 01, 2015, 05:57:21 pm »
I accuse UpdateThreadsEvents and that you are not checking for csLoading in ComponentState in the setter. You can check that the setter is being called.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9792
  • Debugger - SynEdit - and more
    • wiki
Re: published properties
« Reply #8 on: February 01, 2015, 06:20:41 pm »
Debug the IDE (open ide/lazarus.lpi and F9), when you open the form. Set a breakpoint on your setter, and see if it is called.
Maybe it is, but it is undone later?

Also:
Quote
Code: [Select]
if not (csDesigning in ComponentState) then

You should probably also check for csLoading (You may need to check this in the parent object). Unless the code should be run during loading.But even then, it should probably be deferred to OnLoaded.


JimKueneman

  • Full Member
  • ***
  • Posts: 220
Re: published properties
« Reply #9 on: February 26, 2015, 03:02:10 pm »
Finally back to this.  When I try to compile lazarus and run the debugger I get this dialog?

Nothing to do
  The project's compiler options has no compile command
  See Project/Compiler Options.../Compilation


I am not understanding what this means.  Nothing in the Compilation tab looks any different than any of my projects.

Jim

 

TinyPortal © 2005-2018