Board index » delphi » TCanvas EInvalidOperation or EStackOverflow

TCanvas EInvalidOperation or EStackOverflow

Hi,
This is the first time I write to this group. I am trying to controll an
interna combustion engine with a programm written in Delphi5. We are
measuring the cylinder pressure among other things and plotting this in real
time on the screen. A couple of times a day I get EInvalidOperation "Canvas
does not allow drawing" or EStackOverflow in the procedure
TCanvas.RequiredState in the unit Graphics.pas.
I have tried to enlarge the stack, but it did not help at all. The program
is threaded and run in win98 environment. We use two A/D converters, where
one is connected on the parallellport and the other is a PCI multifunction
card. We also communicate with PIC processors for the injection on the other
parallellport.

What should I do to avoid problems with the TCanvas? Am I doing something
very wrong?
G?ran.

 

Re:TCanvas EInvalidOperation or EStackOverflow


Quote
G?ran Haraldsson <goran.haralds...@vok.lth.se> wrote in message

news:adl20j$igv$1@news.lth.se...

Quote
> Hi,
> This is the first time I write to this group. I am trying to controll an
> interna combustion engine with a programm written in Delphi5. We are
> measuring the cylinder pressure among other things and plotting this in
real
> time on the screen. A couple of times a day I get EInvalidOperation
"Canvas
> does not allow drawing" or EStackOverflow in the procedure
> TCanvas.RequiredState in the unit Graphics.pas.
> I have tried to enlarge the stack, but it did not help at all. The program
> is threaded and run in win98 environment. We use two A/D converters, where
> one is connected on the parallellport and the other is a PCI multifunction
> card. We also communicate with PIC processors for the injection on the
other
> parallellport.

> What should I do to avoid problems with the TCanvas? Am I doing something
> very wrong?
> G?ran.

My guess is that you have a GDI resource leak.

TCanvas.RequiredState is involved in allocating new pens, brushes etc, and
if your app is not freeing such resources after use, it is possible to run
out. Have you run a resource checker such as MemProof? With newly developed
realtime data acquisition apps it is also a good idea to have a resource
meter open the whole time they are running just so you can see if they are
running cleanly or not.

Dave

Re:TCanvas EInvalidOperation or EStackOverflow


"David Reeve" <drscienti...@powerup.com.au> skrev i meddelandet
news:jXxL8.5378$3t6.247233@ozemail.com.au...

Quote

> G?ran Haraldsson <goran.haralds...@vok.lth.se> wrote in message
> news:adl20j$igv$1@news.lth.se...
> > Hi,
> > This is the first time I write to this group. I am trying to controll an
> > interna combustion engine with a programm written in Delphi5. We are
> > measuring the cylinder pressure among other things and plotting this in
> real
> > time on the screen. A couple of times a day I get EInvalidOperation
> "Canvas
> > does not allow drawing" or EStackOverflow in the procedure
> > TCanvas.RequiredState in the unit Graphics.pas.
> > I have tried to enlarge the stack, but it did not help at all. The
program
> > is threaded and run in win98 environment. We use two A/D converters,
where
> > one is connected on the parallellport and the other is a PCI
multifunction
> > card. We also communicate with PIC processors for the injection on the
> other
> > parallellport.

> > What should I do to avoid problems with the TCanvas? Am I doing
something
> > very wrong?
> > G?ran.

> My guess is that you have a GDI resource leak.

> TCanvas.RequiredState is involved in allocating new pens, brushes etc, and
> if your app is not freeing such resources after use, it is possible to run
> out. Have you run a resource checker such as MemProof? With newly
developed
> realtime data acquisition apps it is also a good idea to have a resource
> meter open the whole time they are running just so you can see if they are
> running cleanly or not.

> Dave

No it is not a GDI resource leak. I have checked the GDI resources with
resmon.exe and they are never below 66% free.
/G?ran.

Re:TCanvas EInvalidOperation or EStackOverflow


Quote
G?ran Haraldsson <goran.haralds...@vok.lth.se> wrote in message

news:adqi5m$rqf$1@news.lth.se...

Quote

> "David Reeve" <drscienti...@powerup.com.au> skrev i meddelandet
> news:jXxL8.5378$3t6.247233@ozemail.com.au...

> > G?ran Haraldsson <goran.haralds...@vok.lth.se> wrote in message
> > news:adl20j$igv$1@news.lth.se...
> > > Hi,
> > > This is the first time I write to this group. I am trying to controll
an
> > > interna combustion engine with a programm written in Delphi5. We are
> > > measuring the cylinder pressure among other things and plotting this
in
> > real
> > > time on the screen. A couple of times a day I get EInvalidOperation
> > "Canvas
> > > does not allow drawing" or EStackOverflow in the procedure
> > > TCanvas.RequiredState in the unit Graphics.pas.
> > > I have tried to enlarge the stack, but it did not help at all. The
> program
> > > is threaded and run in win98 environment. We use two A/D converters,
> where
> > > one is connected on the parallellport and the other is a PCI
> multifunction
> > > card. We also communicate with PIC processors for the injection on the
> > other
> > > parallellport.

> > > What should I do to avoid problems with the TCanvas? Am I doing
> something
> > > very wrong?
> > > G?ran.

> > My guess is that you have a GDI resource leak.

> > TCanvas.RequiredState is involved in allocating new pens, brushes etc,
and
> > if your app is not freeing such resources after use, it is possible to
run
> > out. Have you run a resource checker such as MemProof? With newly
> developed
> > realtime data acquisition apps it is also a good idea to have a resource
> > meter open the whole time they are running just so you can see if they
are
> > running cleanly or not.

> > Dave

> No it is not a GDI resource leak. I have checked the GDI resources with
> resmon.exe and they are never below 66% free.
> /G?ran.

Goran,

Another thought has occured to me. You say the application is threaded. Are
you absolutely sure you don't call the VCL from somewhere within the thread?

Dave

Other Threads