Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.

Welcome, Guest
Guest Settings

Thread: AV's trying to create, install & use the world's simplest FMX component?

This question is not answered. Helpful answers available: 2. Correct answers available: 1.

Permlink Replies: 1 - Last Post: May 27, 2016 5:31 AM Last Post By: Lajos Juhasz
Free Dorfman

Posts: 139
Registered: 2/4/12
AV's trying to create, install & use the world's simplest FMX component?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 26, 2016 2:21 PM
10.1 Berlin * Delphi * FMX * Windows 10

The only thing I can think of here is that I am NOT USING STYLES at all. Although, if this is my problem, I cannot imagine why...

I am getting AV's trying to create/install/use a custom FMX component. I have boiled this down to a TINY test case:

Step 1 - File | New | Unit - Delphi

unit zzTestBtn;
  [ComponentPlatformsAttribute  //this is LINE NUMBER 9 (see below)
    (pidWin32 or pidWin64 or pidOSX32 or pidiOSDevice32 or pidiOSDevice64 or pidAndroid)]
  TjzzBtn = class(TRectangle)
procedure Register;
  System.Classes, FMX.Types;
procedure Register;

Save as zzTestBtn --all these files saved in the same folder.

Step 2 - File | New | Package - Delphi

Project | Add to Project...
select zzTestBtn
Delphi asks Confirm ...enable the "FireMonkey" framework for this project? I respond with [Yes]

Step 3 - File | Save Project As...

Save as zzTestPackage

Step 4 - Project | Compile zzTestPackage <Ctrl+F9>

Delphi compiles and asks Change zzTestPackage.dproj ...Add fmx I respond with [OK]
Delphi again/re-compiles.
I get a bunch of W1033 warnings: Unit 'SuchAndSuch' implicitly imported into package...
I get 16 W1025 warnings: Unsupported language feature: 'class con/destructor' from various FMX units
I also get - and this might be a clue - W1025 Unsupported language feature: 'custom attribute' on line 9 of zzTestBtn.pas

Test App (Project1)

Step 5 - File | New | Multi-device Application - Delphi

Drop a TButton on the form and add:
//NOTE: need zzTestBtn in uses clause (put it up top for later)
procedure TForm1.Button1Click(Sender: TObject);
  B: TjzzBtn;
B := TjzzBtn.Create(Self);
B.Parent := Self;
B.Position.Y := (Sender as TButton).Position.Y + (Sender as TButton).Height + 8;
B.Position.X := (Sender as TButton).Position.X;
B.Width      := (Sender as TButton).Width;
B.Height     := (Sender as TButton).Height;

Run app; click button; all's well

Step 6 - File | Close All

Step 7 - Component | Install Packages...

Click [Add...]
Select zzTestPackage.bpl (from C:\Users\Public\Documents\Embarcadero\Studio\18.0\Bpl)
Click [OK]

Now I have problems!

File | Close All
File | Exit

backup the files!

restart Delphi
File | Reopen Project1
Component | Install Packages...
Check the newly added zzTestPackage.bpl
Click [OK]
Drop a TjzzBtn on the form
Compile; run; etc -- All is well

So... What's the problem?

File | Reopen zzTestPackage
Project | Compile zzTestPackage <Ctrl+F9>
File | Reopen Project1
(if Form1 is not visible, you'll need to [attempt to] make it visible)
SPLAT Access violation in rtl420.bpl

A few final points:
(1) As soon as the SPLAT above happens, I need to either restore source or remove the TjzzBtn (outside of Delphi) before proceeding
(2) It seems like 95% of the time I recompile zzTestPackage I get a SPLAT the next time I attempt to look at a form with one of these TjzzBtns on it. But not 100% of the time.
(3) For a while, when this SPLATting happened, I'd just close & re-open Delphi [figuring I'd get to it later]. FWIW: This close & reopening of Delphi almost always (maybe always always) meant I wouldn't see this SPLAT again until the next time I rebuilt (re-compiled) the package. [See PLEASE KEEP IN MIND below for why I need to figure out what's happening here.]
(4) This is all being done under in a fresh 10.1 Berlin environment. However, the underlying behaviors listed below and the AVs have been happening for a while, in 10 Seattle.
(5) I have added nothing to my environment other than TFrameStand and full-blown CodeSite (neither of which, clearly, are being used here).

PLEASE KEEP IN MIND that I boiled this down to the above TINY test scenario. Whatever is happening here I believe is responsible for bigger issues I'm having with my full-blow Button component resulting in memory leaks and mysterious underscore-looking things appearing in various places (changing from run to run) within my actual app. In my actual app, the reported memory leaks (only in Berlin; not Seattle) are 1 - 12 bytes | TWinAcceleratorKeyRegistry.TAcceleratorKeyReceivers x 1

BUT... All the same... the above scenario is clearly indicative of some Delphi flaw?

Or, is there something simple I've overlooked?

MANY Thanks on this one,
-Free Dorfman

Lajos Juhasz

Posts: 801
Registered: 3/14/14
Re: AV's trying to create, install & use the world's simplest FMX component? [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 27, 2016 5:31 AM   in response to: Free Dorfman in response to: Free Dorfman
Free Dorfman wrote:


You have ommited some required units from the uses. Try to add to the
interface section in zzTestBtn:

  System.Classes,FMX.Objects, FMX.Dialogs, FMX.DialogService.Sync,   
  FMX.Ani, FMX.MultiResBitmap, FMX.Effects, FMX.Filter.Custom, 

Most probably System.Classses should be enough but why not add the
other units that are listed by the compiler. With this modification I
didn't had any trouble.

Of course I should note that I don't use the FMX framework.

Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02