Annoying FireMonkey buglet/oversight of the week

My personal FireMonkey buglet/oversight of the week is this: setting a TTextControl descendant’s Text property inside its constructor doesn’t do anything. For those who don’t know, TTextControl is the base class for things like TLabel, TListBoxItem and TExpander in FMX. Create custom descendants of these, then, and the following sort of code will not work:

type
  TMyExpander = class(TExpander)
  public
    constructor Create(const AOwner: TComponent;
      const AText: string); reintroduce;
  end;

constructor TMyExpander.Create(const AOwner: TComponent;
   const AText: string);
begin
  inherited Create(AOwner);
  Text := AText;
end;

The reason is quite simple: TTextControl sets a flag in Create that prevents changes to the Text property doing anything until that flag is reset in an override of AfterConstruction. In true ‘FM squared’ fashion, the code is nevertheless convoluted enough to give you RSI from having to press F7 so much in trying to track this down. Argh!!!!

Advertisements

7 thoughts on “Annoying FireMonkey buglet/oversight of the week

    • Well… it could be worse. The fact you have the source does mean you can easily enough track down the actual cause of dodgy behaviour when it happens. While you get the source with the VCL too of course, the FMX source has (even) greater utility given FMX controls aren’t ultimately wrappers round black boxes like most of their VCL equivalents.

      • >The fact you have the source does mean you can easily enough
        >track down the actual cause of dodgy behaviour when it happens.

        From another point of view, there’s something similar to that called “open source”. Its two advantages are that if any one person does track down the cause, they can make changes that benefit everyone else, and it’s free. When one pays at least $1000USD one generally expects the bug hunting to have been done already. 😦 Firemonkey is becoming like the worst of both options.

        • From another point of view, there’s something similar to that called “open source”.

          Did you actually bother to read what I wrote? The comparison was with the VCL, though it might as well have been with the LCL, which is under a LGPL variant.

          Firemonkey is becoming like the worst of both options.

          No it isn’t. Let me guess: you don’t actually have direct experience of FMX in XE3, do you?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s