Hello,
I always get a stack overload error in your source of LoadChartFromStream if I use LoadChartFromStream(TCustomChart(QRDBChart1), aMemoryStream) the second time. The stack overload error happens if your component tries to free up all series and the other resources of the TChart that was loaded with the first LoadChartFromStream.
The first time if LoadChartFromStream loads the destination TChart in an empty TQRDBChart all is ok. QRDBChart1 is the TQRDBChart component of a TQRChart on a TQuickrep. I’ve got the same stack overload error if I use QRChart1.SetChart().
I use Delphi 7 Enterprise Build 4.453 with Quickreport 4.05 and TeeChart Pro 7.04. With Delphi 5 Enterprise, Quickreport 3.62 and TeeChart Pro 5 I get no stack overload error if I use LoadChartFromStream(TCustomChart(QRDBChart1), aMemoryStream) many times.
Problem with LoadChartFromStream(TCustomChart(QRDBChart1)
-
- Newbie
- Posts: 7
- Joined: Tue Sep 07, 2004 4:00 am
- Contact:
Hi,
do you reset the stream position to 0 ? i.e., using similar code like the following ?
do you reset the stream position to 0 ? i.e., using similar code like the following ?
Code: Select all
tmpStream := tmpDS.CreateBlobStream(YourBlobField,bmRead);
try
LoadChartFromStream(TCustomChart(Chart1),tmpStream);
finally
tmpStream.Free;
end;
Pep Jorge
http://support.steema.com
http://support.steema.com
-
- Newbie
- Posts: 7
- Joined: Tue Sep 07, 2004 4:00 am
- Contact:
Thank you for your answer.
Yes i do:
I found a workaraound, i can now display the chart many times. But if i free the PsQRChart1.Chart i get a stack overload error too.
var
PsQRChart1: TQRChart;
QRDBChart1: TQRDBChart;
begin
PsQRChart1:=TQRChart.Create(Self);
With TQRDBChart.Create(PsQRChart1) do
begin
Parent:=TWinControl(PsQRChart1);
Name:=TeeGetUniqueName(Owner,'QRChart');
end;
With PsQRChart1 do
begin
ParentReport:=QuickReportStruktur;
Parent:=PageFooterBand1;
end;
QRDBChart1 := PsQRChart1.Chart ;
try
PsQRChart1.Enabled := true;
aPlChart := TGraphForm.Create (self);
aMemoryStream := TMemoryStream.Create ;
SaveChartToStream(TCustomChart(aPlChart.Chart1), aMemoryStream);
aMemoryStream.Position := 0;
LoadChartFromStream(TCustomChart(QRDBChart1), aMemoryStream);
// display the chart
finally
//PsQRChart1.Chart.free; -> stack overload error
PsQRChart1.free;
end;
end;
Yes i do:
I found a workaraound, i can now display the chart many times. But if i free the PsQRChart1.Chart i get a stack overload error too.
var
PsQRChart1: TQRChart;
QRDBChart1: TQRDBChart;
begin
PsQRChart1:=TQRChart.Create(Self);
With TQRDBChart.Create(PsQRChart1) do
begin
Parent:=TWinControl(PsQRChart1);
Name:=TeeGetUniqueName(Owner,'QRChart');
end;
With PsQRChart1 do
begin
ParentReport:=QuickReportStruktur;
Parent:=PageFooterBand1;
end;
QRDBChart1 := PsQRChart1.Chart ;
try
PsQRChart1.Enabled := true;
aPlChart := TGraphForm.Create (self);
aMemoryStream := TMemoryStream.Create ;
SaveChartToStream(TCustomChart(aPlChart.Chart1), aMemoryStream);
aMemoryStream.Position := 0;
LoadChartFromStream(TCustomChart(QRDBChart1), aMemoryStream);
// display the chart
finally
//PsQRChart1.Chart.free; -> stack overload error
PsQRChart1.free;
end;
end;
I have encountered a similar problem when using a third party component and TeeChart. For me the problem was that BOTH Teechart and the Third party component were creating "unnamed" components. In the case of teechart, I think an unnamed chart is created durring the streaming process. This causes problems on the second time a chart is streamed(and freed as suggested in this forum to load the default properties). The solution is to modify the source code of either teechart or the other component to NOT USE unnamed components during streaming operations, in fact ever.
-
- Newbie
- Posts: 7
- Joined: Tue Sep 07, 2004 4:00 am
- Contact:
Willi,
The unnamed component is not in your code, it is in the internal teechart loadfromfile code, that code creates an unnamed chart, I think, when loading a chart from a file. For me this created a conflict with another component on my form which internally had also created an unnamed component. Which caused a conflict. This was totally hidden from me.
a snippet of the code I used to recall saved chart settings is:
var
tmp : TCustomChart;
begin
.....
tmp := TChart.Create(PlotChart.owner);
LoadChartFromFile(TCustomChart(tmp),FN);
tmp.Parent := PlotChart.Parent;
tmp.Parent := self;
PlotChart.Free;
PlotChart := tmp as TChart;
The second time this code was executed I always got errors. The problem was that I had a component on the form that created an unnamed form and somewhere in Teechart's LoadFromFile an unnamed component would also be created causing problems when I freed the "old" chart. You can test this in your code by replacing the line
tmp := TChart.Create(PlotChart.owner);
with
tmp := TChart.Create(nil);
this never fails as the unnamed componet is never freed, of course this is not fix.
Finally, perhaps we had different problems. I just know that every time I loaded the setting for the same chart twice in a row my app would fail, but only if I also used the third party control, which did allow us to track down the error. And was because both Teechart and the third party control created unnamed controls at runtime.
Dan
The unnamed component is not in your code, it is in the internal teechart loadfromfile code, that code creates an unnamed chart, I think, when loading a chart from a file. For me this created a conflict with another component on my form which internally had also created an unnamed component. Which caused a conflict. This was totally hidden from me.
a snippet of the code I used to recall saved chart settings is:
var
tmp : TCustomChart;
begin
.....
tmp := TChart.Create(PlotChart.owner);
LoadChartFromFile(TCustomChart(tmp),FN);
tmp.Parent := PlotChart.Parent;
tmp.Parent := self;
PlotChart.Free;
PlotChart := tmp as TChart;
The second time this code was executed I always got errors. The problem was that I had a component on the form that created an unnamed form and somewhere in Teechart's LoadFromFile an unnamed component would also be created causing problems when I freed the "old" chart. You can test this in your code by replacing the line
tmp := TChart.Create(PlotChart.owner);
with
tmp := TChart.Create(nil);
this never fails as the unnamed componet is never freed, of course this is not fix.
Finally, perhaps we had different problems. I just know that every time I loaded the setting for the same chart twice in a row my app would fail, but only if I also used the third party control, which did allow us to track down the error. And was because both Teechart and the third party control created unnamed controls at runtime.
Dan