Recent

Author Topic: [SOLVED] I cannot compile my LPK in Lazarus 1.6 when using an empty property  (Read 7678 times)

CM630

  • Hero Member
  • *****
  • Posts: 1674
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
I have updated Lazarus to 1.6 recently and it occurs that I cannot compile one of my LPKs.
In the pas file I have:
Code: Pascal  [Select][+][-]
  1.  TArrowStar = class(TCustomControl)
  2.  
  3. ...
  4. published
  5. ...
  6. property RepetitiveMode :Boolean read FRepetitiveMode write FRepetitiveMode;    //Enable/disable repetitive mode
  7.     property RepeatsUntilFastRate :Cardinal read FRepeatsUntilFastRate write FRepeatsUntilFastRate;  //How many times the control shall be actuated, in repetitive mode, until it switches to fast rate
  8.     property Height: Integer; //Prevent Height form being shown in the Properties panel of the Object Browser
  9.     property Width:  Integer; //Prevent Width form being shown in the Properties panel of the Object Browser
  10. ...
  11.  
   
I get the following message arrowstar.pas(113,29) Fatal: Syntax error, "READ" expected but ";" found on property Height: Integer;
I did not have this problem with previous version of Lazarus  >:D
« Last Edit: April 09, 2016, 09:34:51 pm by CM630 »
Лазар 4,4 32 bit (sometimes 64 bit); FPC3,2,2

Thaddy

  • Hero Member
  • *****
  • Posts: 18932
  • Glad to be alive.
Re: I cannot compile my LPK in Lazarus 1.6 when using an empty property
« Reply #1 on: April 05, 2016, 08:50:16 pm »
That is a visibility re-declaration. Did you check the base class? That might have changed.
Recovered from removal of tumor in tongue following tongue reconstruction with a part from my leg.

CM630

  • Hero Member
  • *****
  • Posts: 1674
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: I cannot compile my LPK in Lazarus 1.6 when using an empty property
« Reply #2 on: April 06, 2016, 08:56:10 am »
If I undestartand you right by „Did you check the base class? That might have changed.‟ you meant „Did you check if the Height and Width property still exist in the TCustomControl class‟.Yes, they do. Could this error be due to a bug in Lazarus/FPC?
« Last Edit: April 06, 2016, 04:55:17 pm by CM630 »
Лазар 4,4 32 bit (sometimes 64 bit); FPC3,2,2

Thaddy

  • Hero Member
  • *****
  • Posts: 18932
  • Glad to be alive.
Re: I cannot compile my LPK in Lazarus 1.6 when using an empty property
« Reply #3 on: April 06, 2016, 09:23:56 am »
Well, can you provide a simple compilable/crashable/refusing to compile  example?
Because it looks like a bug, but in that case the whole LCL should fall apart and that is not the case.

A possible explanation is that there are some dirty files. So clean up and rebuild.

« Last Edit: April 06, 2016, 09:40:48 am by Thaddy »
Recovered from removal of tumor in tongue following tongue reconstruction with a part from my leg.

CM630

  • Hero Member
  • *****
  • Posts: 1674
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: I cannot compile my LPK in Lazarus 1.6 when using an empty property
« Reply #4 on: April 06, 2016, 05:01:37 pm »
Well, can you provide a simple compilable/crashable/refusing to compile  example?
The source is here, I checked that it does not need some special dependencies, so I guess there is no reason to make it shorter?
Лазар 4,4 32 bit (sometimes 64 bit); FPC3,2,2

wp

  • Hero Member
  • *****
  • Posts: 13484
Re: I cannot compile my LPK in Lazarus 1.6 when using an empty property
« Reply #5 on: April 06, 2016, 06:32:07 pm »
In a property redeclaration you only specify the property name, not the property type.

But your comment shows that you want to hide the "Height" and "Width" properties in the object inspector. Did you try "RegisterPropertyToSkip()" (in LResources)?

CM630

  • Hero Member
  • *****
  • Posts: 1674
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: I cannot compile my LPK in Lazarus 1.6 when using an empty property
« Reply #6 on: April 07, 2016, 01:47:49 pm »

I changed
Code: Pascal  [Select][+][-]
  1.    property Height: Integer; //Prevent Height form being shown in the Properties panel of the Object Browser
  2.    property Width:  Integer; //Prevent Width form being shown in the Properties panel of the Object Browser
  3.  
to
I changed
Code: Pascal  [Select][+][-]
  1.  property Height; //: Integer; //Prevent Height form being shown in the Properties panel of the Object Browser
  2.  property Width; //:  Integer; //Prevent Width form being shown in the Properties panel of the Object Browser
  3.  
Now it compiles, but Height and Width are shown in the Object Inspector.
I will check where exactly shall I put RegisterPropertyToSkip and report back.
Лазар 4,4 32 bit (sometimes 64 bit); FPC3,2,2

balazsszekely

  • Guest
Re: I cannot compile my LPK in Lazarus 1.6 when using an empty property
« Reply #7 on: April 07, 2016, 01:59:12 pm »
Quote
@CM630
Now it compiles, but Height and Width are shown in the Object Inspector.
Just move Width and Height from published to public section and you're good to go:
Code: Pascal  [Select][+][-]
  1. type
  2.   TArrowStar = class(TCustomControl)
  3.   private
  4.     FRepetitiveMode :Boolean;
  5.     FRepeatsUntilFastRate :Cardinal;
  6.   public
  7.     property Height;
  8.     property Width;
  9.   published
  10.     property RepetitiveMode :Boolean read FRepetitiveMode write FRepetitiveMode;
  11.     property RepeatsUntilFastRate :Cardinal read FRepeatsUntilFastRate write FRepeatsUntilFastRate;
  12.   end;

CM630

  • Hero Member
  • *****
  • Posts: 1674
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: I cannot compile my LPK in Lazarus 1.6 when using an empty property
« Reply #8 on: April 07, 2016, 08:15:20 pm »
But your comment shows that you want to hide the "Height" and "Width" properties in the object inspector. Did you try "RegisterPropertyToSkip()" (in LResources)?
I tried. I added
   
Code: Pascal  [Select][+][-]
  1. RegisterPropertyToSkip(TArrowStar, 'Height','', '');
  2.     RegisterPropertyToSkip(TArrowStar, 'Width','', '');
 
in
Code: Pascal  [Select][+][-]
  1. constructor TArrowStar.Create (aOwner: TComponent);
  2.   function CreateArrow(ArrowType:TArrowType):TArrow;
  3.   begin
           


also in
Code: Pascal  [Select][+][-]
  1. procedure Register;
  2. begin
  3.   {.$I arrowstar_icon.lrs}
  4. RegisterPropertyToSkip(TArrowStar, 'Height','', '');
  5.     RegisterPropertyToSkip(TArrowStar, 'Width','', '');
   


and also in
Code: Pascal  [Select][+][-]
  1. initialization
  2.        RegisterPropertyToSkip(TArrowStar, 'Height','', '');
  3.     RegisterPropertyToSkip(TArrowStar, 'Width','', '');
  4.  

All in vane!


 
  public
    property Height;
    property Width;
That not working neither

     
« Last Edit: April 07, 2016, 08:17:02 pm by CM630 »
Лазар 4,4 32 bit (sometimes 64 bit); FPC3,2,2

balazsszekely

  • Guest
Re: I cannot compile my LPK in Lazarus 1.6 when using an empty property
« Reply #9 on: April 07, 2016, 08:49:45 pm »
Quote
That not working neither
Try again, because it works!

wp

  • Hero Member
  • *****
  • Posts: 13484
Re: I cannot compile my LPK in Lazarus 1.6 when using an empty property
« Reply #10 on: April 07, 2016, 10:59:19 pm »
Quote
That not working neither
Try again, because it works!
It's not working with me either. I always thought that it is not possible to decrease the visibility level of a property, but the RegisterPropertyToSkip which I saw in some TAChart code confuses me. Maybe it refers to property identifiers which may be in the lfm file but which actually are not available in the class. Importing dfm files from Delphi may present such a situation.

The Width and Height properties were published in the first place when they were introduced in TControl. Probably because Delphi does it the same way. In my eyes, a severe design fault because descendent classes never can hide these properties (and some more) in the Object Inspector.

@CM630: What is the problem to have these properties in the Object Inspector?

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1269
Re: I cannot compile my LPK in Lazarus 1.6 when using an empty property
« Reply #11 on: April 08, 2016, 12:27:29 am »
I always thought GetMem's solution would work as well.

This may help.
See Mattias Gaertner's reply
http://comments.gmane.org/gmane.comp.ide.lazarus.general/84290
Quote
On Wed, 11 Nov 2015 18:45:52 +0100
Gabor Boros <gaborboros <at> yahoo.com> wrote:

> Hi All,
>
> I use a property grid in my application and don't want to advertise my
> class names to the users. For example (TSizeConstraints) displayed next
> to Contraints. Any idea how to hide class names or override at
> object(TPersistent) level?

You cannot decrease visibility in Free Pascal.
You can hide properties in the Object inspector. For example

  RegisterPropertyEditor(TypeInfo(TAnchorSide), TControl, 'AnchorSideLeft', THiddenPropertyEditor);

Mattias
Lazarus Trunk/FPC latest fixes on Windows 11
  I'm getting old and stale.  Slowly getting used to git, I'll get there...

wp

  • Hero Member
  • *****
  • Posts: 13484
Re: I cannot compile my LPK in Lazarus 1.6 when using an empty property
« Reply #12 on: April 08, 2016, 12:50:51 am »
Ah, thanks, Mike  - this works.

@CM630: Add these lines to the Register procedure:
Code: Pascal  [Select][+][-]
  1.   RegisterPropertyEditor(TypeInfo(integer), TArrowStar, 'Width', THiddenPropertyEditor);
  2.   RegisterPropertyEditor(TypeInfo(integer), TArrowStar, 'Height', THiddenPropertyEditor);
This requires propedits in the uses clause of the unit and package ideintf in the package requirements.

But note that these properties still can be accessed at runtime.
« Last Edit: April 08, 2016, 12:57:39 am by wp »

balazsszekely

  • Guest
Re: I cannot compile my LPK in Lazarus 1.6 when using an empty property
« Reply #13 on: April 08, 2016, 05:10:08 am »
@wp, @Mike.Cornflake
https://youtu.be/iLhPKiJf1ww

wp

  • Hero Member
  • *****
  • Posts: 13484
Re: I cannot compile my LPK in Lazarus 1.6 when using an empty property
« Reply #14 on: April 08, 2016, 10:20:54 am »
"Width" and "Height" are "published" from the very first ancestor ever. Making it "public" means to decrease its visibility from "published" to "public" which is not possible.

The property "Visible" of your property, however, always has been "public". Your video decreases the visibility of this property of TButton to "public", but the ancestor of TButton, TCustomButton, had it as a "public" property already. Therefore your video works because you don't reduce visibility at all. Try to make the property "protected" - I guess this will not work...

 

TinyPortal © 2005-2018