Exception on opening form with component using TChart

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Collinor
Newbie
Newbie
Posts: 12
Joined: Wed Oct 16, 2013 12:00 am

Exception on opening form with component using TChart

Post by Collinor » Fri Jul 25, 2014 6:50 am

TeeChart 2014: If I write a component which is a descendant of TPanel and which creates a TChart in the constructor with owner being Self, then any form on which my component was/is put cannot be opened in the Delphi IDE (design time), since an exception (translated from German):
access violation at address 504F0554 in module vcl200.bpl. reading address 00000000
is thrown. The exception is not thrown at run-time.

If I pass nil or the panel's owner as owner to TChart.Create everything is fine.
Here's an outline of the component:

Code: Select all

interface

type
  TCollChartPanel = class(TPanel)
  private
    FChart           : TChart;
...
  public
    constructor Create(Owner : TComponent); override;
...
end;
...
procedure Register;

implementation
...
constructor TCollChartPanel.Create(Owner : TComponent);
begin
  inherited;

  Self.Parent      := Owner as TWinControl;
  Self.BevelOuter  := bvNone;
  Self.BevelInner  := bvNone;
  Self.BorderStyle := bsNone;

  FChart        := TChart.Create(Self); // nil or Owner works fine
  FChart.Parent := Self;
  FChart.Align  := alClient;
end;
...

procedure Register;
begin
  RegisterComponents('Collinor', [TCollChartPanel]);
end;

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Exception on opening form with component using TChart

Post by Sandra » Tue Jul 29, 2014 9:51 am

Hello Collinor,

Thanks for your information. Could you please arrange for us a simple applications with your own component, because we can check if the exception occurs here and we try to find a solution for it?

Thanks in advance,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Collinor
Newbie
Newbie
Posts: 12
Joined: Wed Oct 16, 2013 12:00 am

Re: Exception on opening form with component using TChart

Post by Collinor » Sun Aug 17, 2014 12:04 pm

With Delphi's menu entry Component/New Component... create a new component TCollChartPanel in unit CollChartPanel with the following code and put it in a new package with name Coll:

Code: Select all

unit CollChartPanel;

interface

uses
  System.SysUtils, System.Classes, Vcl.Controls, Vcl.ExtCtrls, VCLTee.Chart;

type
  TCollChartPanel = class(TPanel)
  private
    { Private-Deklarationen }
    FChart           : TChart;
  protected
    { Protected-Deklarationen }
  public
    { Public-Deklarationen }
    constructor Create(Owner : TComponent); override;
  published
    { Published-Deklarationen }
  end;

procedure Register;

implementation

uses
  Forms; // bsNone

procedure Register;
begin
  RegisterComponents('Samples', [TCollChartPanel]);
end;

constructor TCollChartPanel.Create(Owner : TComponent);
begin
  inherited;

  Self.Parent      := Owner as TWinControl;
  Self.BevelOuter  := bvNone;
  Self.BevelInner  := bvNone;
  Self.BorderStyle := bsNone;

  FChart        := TChart.Create(Self); // nil or Owner works fine
  FChart.Parent := Self;
  FChart.Align  := alClient;
end;

end.
Compile the Coll package and install it.
Then, create a new VCL application, put the CollChartPanel component (found in the Samples tool palette) on the main form and save and close the project.
Now reopen the project and you'll see that an exception is raised and the main form won't open.
Next, open the Coll package again, and change the line

Code: Select all

  FChart        := TChart.Create(Self); // nil or Owner works fine
into

Code: Select all

  FChart        := TChart.Create(Owner); // nil or Owner works fine
recompile the package and close the project.
Finally, reopen the VCL application with the TCollChartPanel component on the main form and you'll see that the main form will open without error.

Yeray
Site Admin
Site Admin
Posts: 9611
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Exception on opening form with component using TChart

Post by Yeray » Tue Aug 19, 2014 2:57 pm

Hello,

This worked fine for me in Delphi 7.
testComponent.zip
(6.44 KiB) Downloaded 921 times
I'll try it with XE6 and let you know asap.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Yeray
Site Admin
Site Admin
Posts: 9611
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Exception on opening form with component using TChart

Post by Yeray » Tue Aug 19, 2014 3:08 pm

Hello again,

It worked without problems for me also in XE6:
testComponentXE6.zip
(6.48 KiB) Downloaded 955 times
testColl.zip
(4.09 KiB) Downloaded 893 times
I'm using TeeChart v2014.11, and you?
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Yeray
Site Admin
Site Admin
Posts: 9611
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Exception on opening form with component using TChart

Post by Yeray » Tue Aug 19, 2014 3:11 pm

Hello,

Sorry, I missed the last part:
Collinor wrote:Now reopen the project and you'll see that an exception is raised and the main form won't open.
I've reproduced the problem now.
We'll investigate it and let you know asap.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Yeray
Site Admin
Site Admin
Posts: 9611
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Exception on opening form with component using TChart

Post by Yeray » Wed Aug 20, 2014 8:53 am

Hello,

I've created a ticket in the public tracker:
http://bugs.teechart.net/show_bug.cgi?id=893
Feel free to add your mail to the CC list to be automatically notified when an update arrives.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply