casua access violation

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Chartist
Newbie
Newbie
Posts: 60
Joined: Wed Sep 18, 2013 12:00 am

casua access violation

Post by Chartist » Sat Mar 22, 2014 12:17 pm

Hi,

I draw the header of a chart to print by my own.
This works fine in about 50% of all cases.

In the rest there is the message of an access violation.
I have no idea what makes the difference.
I only found the line: The line below throws an exception in about 50% of all cases.
No commons can be found. Sometimes on the first attempt after the software restart, - it works, sometimes it does not.
In the debug window the values of Chart1.Title.ShapeBounds, Chart1, etc. look normal and fine.

So this is the critical line:

Code: Select all

try
   Chart1.Canvas.Rectangle(Chart1.Title.ShapeBounds);
except
    ShowMessage('the nasty line did it again');
 end;
Have you any ideas, what I can to to find the problem?
Any repaint, reset, clear,.... any debug?

I cannot post the whole project or a the part containing it.
The project is too huge and nested.

Thanks,
Cheryll
Cheryll

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

Re: casua access violation

Post by Yeray » Mon Mar 24, 2014 4:03 pm

Hello Cheryll,
Chartist wrote:I cannot post the whole project or a the part containing it.
The project is too huge and nested.
Without any error message nor a project we can run to reproduce the problem here, it's difficult to say.
Note you can get a snapshot of the chart you have at a moment exporting it to a tee file. Then you can try to reproduce the problem loading that tee file in an empty chart in a new simple project with just. If you can't reproduce the problem there, maybe there's some event you are using in the big project that can be causing a conflict.
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

Chartist
Newbie
Newbie
Posts: 60
Joined: Wed Sep 18, 2013 12:00 am

Re: casua access violation

Post by Chartist » Tue Mar 25, 2014 3:01 pm

Thank you for your reply.

I am aware of the "stupid" question I am asking.
Worst of all: The error occurs one time and next time NOT - after exactly the same mouse-clicks! -

May be, the thing has nothing to do with Steema, but with an internal handle within the Delphi IDE.

For now I removed all units and added them again.
Suddenly my Delphi gave me a lot of errors and warning, which have not been there before.
Perhaps the thing was IDE hiccup.

If you are interested, watch for a follow up within 3 weeks.
Then I will know, if the problem is gone. It occurred only occasionally. Since the relaunch it did not.

Regards,
Cheryll
Cheryll

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

Re: casua access violation

Post by Yeray » Tue Mar 25, 2014 3:07 pm

Hi Cheryll,
Chartist wrote:If you are interested, watch for a follow up within 3 weeks.
Then I will know, if the problem is gone. It occurred only occasionally. Since the relaunch it did not.
Of course, we are always interested in detecting and investigate possible bugs in the software we develop and maintain.
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

Chartist
Newbie
Newbie
Posts: 60
Joined: Wed Sep 18, 2013 12:00 am

Re: casua access violation

Post by Chartist » Sat Mar 29, 2014 6:13 pm

Hi,

the access violation keeps coming (occasionally).
I took a screenshot of the line causing it and the values of the vars I can see in the debugging window.

I am really unexperience with those drawing of headers.
From that point of view I would expect somehing being calle "Rectangle" in the list, - but I cannot see it.


Regards,
Cheryll
Attachments
ProtectionDefault.jpg
Hi,

the access violation keeps coming (occasionally).
I took a screenshot of the line causing it and the values of the vars I can see in the debugging window.

I am really unexperience with those drawing of headers.
From that point of view I would expect somehing being calle "Rectangle" in the list, - but I cannot see it.


Regards,
Cheryll
ProtectionDefault.jpg (151.55 KiB) Viewed 15654 times
Cheryll

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

Re: casua access violation

Post by Yeray » Mon Mar 31, 2014 11:09 am

Hi Cheryll,

We'd need a simple application that reproduces the problem consistently. If you can reduce the application to the minimum expression that reproduces that problem, we'll be glad to debug it to see is we find the root of the problem.
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

Chartist
Newbie
Newbie
Posts: 60
Joined: Wed Sep 18, 2013 12:00 am

Re: casua access violation

Post by Chartist » Mon Mar 31, 2014 12:03 pm

Hi,

thank you for the reply.
There is no minimum application thinkable, as it is the problem by itsself, that the error occurs somewhere in nesting and pasting.
And one more there is not such a thing like a minimum application, as this is a SOMETIMES mistake.
Exactly the same mouse clicks cause sometimes the error and sometimes not.
(I am even more unhappy about this than you.)

To my mind, there is a situation, where "there is no rectangle".
In other words: How can I make sure, that the rectangle, I want to draw, never ever points to nil?
As you can see in the screenshot, there is no parameter rectangle listed.


Regards,
Cheryll
Cheryll

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

Re: casua access violation

Post by Yeray » Mon Mar 31, 2014 2:20 pm

Hi Cheryll,
Chartist wrote:There is no minimum application thinkable, as it is the problem by itsself, that the error occurs somewhere in nesting and pasting.
And one more there is not such a thing like a minimum application, as this is a SOMETIMES mistake.
Exactly the same mouse clicks cause sometimes the error and sometimes not.
(I am even more unhappy about this than you.)
We always ask for a simple application because it's easier to debug and to find the root of the problem, but also because many times the developer finds there was a mistake in the application.
Without it, it's difficult for us to track where the problem or mistake is.
Chartist wrote:To my mind, there is a situation, where "there is no rectangle".
In other words: How can I make sure, that the rectangle, I want to draw, never ever points to nil?
As you can see in the screenshot, there is no parameter rectangle listed.
Chart's Canvas.Rectangle() is a method, what can't be nil is the Rectangle you pass to it as parameter; in your case it's the Chart's Title.ShapeBounds. Actually, in the call:

Code: Select all

Chart_.Canvas.Rectangle(Chart_.Title.ShapeBounds);
neither Chart_, Chart_.Canvas, Chart_.Title nor Chart_.Title.ShapeBounds can be nil. So the full check would be:

Code: Select all

if (Assigned(Chart_) and Assigned(Chart_.Canvas) and Assigned(Chart_.Title) and Assigned(Chart_.ShapeBounds)) then
  Chart_.Canvas.Rectangle(Chart_.Title.ShapeBounds);
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

Chartist
Newbie
Newbie
Posts: 60
Joined: Wed Sep 18, 2013 12:00 am

Re: casua access violation

Post by Chartist » Sat Apr 05, 2014 9:26 am

Hi,

I keyed it in, waited for the violation to come and found this:

Assigned(Chart_.Title.ShapeBounds)
=> E2008 Incompatible types

Assigned(Chart_.ShapeBounds)
=> E2003 Undeclared identifier: 'ShapeBounds'

The other values are assigned fine.
What can I do? I have no idea, why these things are not assigned.
I never touched them at any other place in my code.

Regards,
Cheryll
Cheryll

Chartist
Newbie
Newbie
Posts: 60
Joined: Wed Sep 18, 2013 12:00 am

Re: casua access violation

Post by Chartist » Sat Apr 05, 2014 9:33 am

I will add you a screenshot. This is the print preview with 10 charts.
Every chart uses the code we are talking about up to 10 times.

And now look at the headers: The very first top left is malformed, the other 9 headers are ok.
The malformed header is the one which is produced, after I gave my Delphi the "continue" after the error.

IF the error occurs, it does it here:
I have a series of such preview charts. The first one works fine.
Then I "let make" the second preview and the third one....
=> the problem occurs on the top left chart header starting with the second page.


Regards,
Cheryll
Attachments
shape bounds.jpg
shape bounds.jpg (223.89 KiB) Viewed 15600 times
Cheryll

Chartist
Newbie
Newbie
Posts: 60
Joined: Wed Sep 18, 2013 12:00 am

Re: casua access violation

Post by Chartist » Sat Apr 05, 2014 10:55 am

One more thing to add.
I found my Delphi (XE3) having occasionally "nesting hiccup". This lead to strange results and unpredictable and unexpected errors.
I give you an example (out of the air):

if (i < StrToInt(myfunction(abc)) then...... => strange behaviour,

but "just the same":

Var s: string;
int: integer;

s:=myfunction(abc);
int:=StrToInt(s);
If (i < int) then..... => suddenly worked

I would to it which Chart_ as well. If I could! I do not know how. Just to do away with the with-loop does not help. I tried it already.
But perhaps you have a better idea than my desperate attempt.

Regards,
Cheryll
Cheryll

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

Re: casua access violation

Post by Yeray » Mon Apr 07, 2014 2:04 pm

Hi Cheryll,
Chartist wrote:I keyed it in, waited for the violation to come and found this:

Assigned(Chart_.Title.ShapeBounds)
=> E2008 Incompatible types

Assigned(Chart_.ShapeBounds)
=> E2003 Undeclared identifier: 'ShapeBounds'

The other values are assigned fine.
What can I do? I have no idea, why these things are not assigned.
I never touched them at any other place in my code.
I'm sorry but the code I suggested to "full check" had an error. Here what I wrote:
yeray wrote:

Code: Select all

if (Assigned(Chart_) and Assigned(Chart_.Canvas) and Assigned(Chart_.Title) and Assigned(Chart_.ShapeBounds)) then
  Chart_.Canvas.Rectangle(Chart_.Title.ShapeBounds);
Here what should be:

Code: Select all

if (Assigned(Chart_) and Assigned(Chart_.Canvas) and Assigned(Chart_.Title) and Assigned(Chart_.Title.ShapeBounds)) then
  Chart_.Canvas.Rectangle(Chart_.Title.ShapeBounds);
However, I guess this change will fix the second error (Undeclared identifier: 'ShapeBounds') but not the first one.
If you still find the first error (Incompatible types for Assigned(Chart_.Title.ShapeBounds)), try removing that check.

Note I can't try that code because I don't have an application to reproduce the problem here. I understand this problem looks like randomly reproduced but it's difficult for us to help without reproducing the situation to handle.
Chartist wrote:I will add you a screenshot. This is the print preview with 10 charts.
Every chart uses the code we are talking about up to 10 times.

And now look at the headers: The very first top left is malformed, the other 9 headers are ok.
The malformed header is the one which is produced, after I gave my Delphi the "continue" after the error.

IF the error occurs, it does it here:
I have a series of such preview charts. The first one works fine.
Then I "let make" the second preview and the third one....
=> the problem occurs on the top left chart header starting with the second page.
I see the problem in images you post but I'd need to reproduce the problem here. Can you arrange a simple example project we can run to reproduce the problem here?
Thanks in advance.
Chartist wrote:One more thing to add.
I found my Delphi (XE3) having occasionally "nesting hiccup". This lead to strange results and unpredictable and unexpected errors.
I give you an example (out of the air):

if (i < StrToInt(myfunction(abc)) then...... => strange behaviour,

but "just the same":

Var s: string;
int: integer;

s:=myfunction(abc);
int:=StrToInt(s);
If (i < int) then..... => suddenly worked

I would to it which Chart_ as well. If I could! I do not know how. Just to do away with the with-loop does not help. I tried it already.
But perhaps you have a better idea than my desperate attempt.
I'm not sure to understand this one. Is this a problem or wish for TeeChart?
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

Chartist
Newbie
Newbie
Posts: 60
Joined: Wed Sep 18, 2013 12:00 am

Re: casua access violation

Post by Chartist » Fri Apr 11, 2014 10:13 am

Yes, please.

This line:
"
Chart1.Canvas.Rectangle(Chart1.Title.ShapeBounds);
"

Can you "unnest" it? Simplify it?
Can you split it into vars like in the integer-string examples above?

Set up some local Vars to do just the same with plain ":=" if possible.
like "a := b;"
Give me a local
"Var rect_: TRect;"
Shape, Bounds etc
and use it and other vars, instead of directly putting them item into the Canvas.

Please write this very line in ugly long and tidious code.

I see you grabbing in the dark in this support, - and I thank you for it!
I really would like to light your guessing by an example. But every simplification will remove the problem, we want to catch.
To my mind the problem is a XE3 bug, which only shows up in Steema, which does nesting and functions being called within other functions. And instances.
Steema reached here a level of complexity, which should work, - but does not.
Just the same code works in a different chart fine for me, and works in my first 10-chart-window fine.
Only the second 10-chart window crashes "sometimes".

So the only thing we can do within Steema is "unnesting".
Cross fingers, it works.
I give it a probability of over 50%.

Regards,
Cheryll
Cheryll

Chartist
Newbie
Newbie
Posts: 60
Joined: Wed Sep 18, 2013 12:00 am

Re: casua access violation

Post by Chartist » Sat Apr 12, 2014 9:04 am

here are the values of the corrected code taken in the exception loop after the access violation
Attachments
corrected code.jpg
corrected code.jpg (21.23 KiB) Viewed 15533 times
Cheryll

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

Re: casua access violation

Post by Yeray » Mon Apr 14, 2014 10:09 am

Hello Cheryll,
Chartist wrote:This line:
"
Chart1.Canvas.Rectangle(Chart1.Title.ShapeBounds);
"

Can you "unnest" it? Simplify it?
Can you split it into vars like in the integer-string examples above?

Set up some local Vars to do just the same with plain ":=" if possible.
like "a := b;"
Give me a local
"Var rect_: TRect;"
Shape, Bounds etc
and use it and other vars, instead of directly putting them item into the Canvas.

Please write this very line in ugly long and tidious code.
In a new simple example with only a chart on the form, I can use the Chart OnAfterDraw event to do this:

Code: Select all

procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
  Chart1.Canvas.Brush.Style:=bsClear;
  Chart1.Canvas.Pen.Color:=clRed;
  Chart1.Canvas.Rectangle(Chart1.Title.ShapeBounds);
end;
And it works without problems. But if you want to spit it in as many vars as possible, here you have it:

Code: Select all

uses TeCanvas;

procedure TForm1.Chart1AfterDraw(Sender: TObject);
var tmpCanvas: TCanvas3D;
    tmpBrush: TTeeBrush;
    tmpPen: TTeePen;
    tmpTitle: TChartTitle;
    tmpRect: TRect;
begin
  tmpCanvas:=Chart1.Canvas;
  tmpBrush:=tmpCanvas.Brush;
  tmpPen:=tmpCanvas.Pen;

  tmpBrush.Style:=bsClear;
  tmpPen.Color:=clRed;
  tmpTitle:=Chart1.Title;
  tmpRect:=tmpTitle.ShapeBounds;

  tmpCanvas.Rectangle(tmpRect);
end;
Chartist wrote:I really would like to light your guessing by an example. But every simplification will remove the problem, we want to catch.
To my mind the problem is a XE3 bug, which only shows up in Steema, which does nesting and functions being called within other functions. And instances.
Steema reached here a level of complexity, which should work, - but does not.
Just the same code works in a different chart fine for me, and works in my first 10-chart-window fine.
Only the second 10-chart window crashes "sometimes".

So the only thing we can do within Steema is "unnesting".
Cross fingers, it works.
I give it a probability of over 50%.
I'm not sure if the example I posted above will help you to find some solution. Don't hesitate to let me know if you still find problems with it.

Another alternative you have is to export all your charts to tee files. Then, if you reach to have a tee file of a chart that reproduce the problem when it is being loaded, we'll have a simple example to track and investigate. Take a look at the "Tee files" section in the "Tutorial 12 - Exporting and Importing Charts".
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