[fpc-pascal] Can't close and reopen ptcgraph

Stefan V. Pantazi svpantazi at gmail.com
Fri Jun 23 18:51:13 CEST 2017


I think I figured it out. It hink ptcgraph was not designed with that 
functionality in mind. If you take a look at the ptcgraph unit, it has 
initialization and finalization sections where the ptc wrapper object is 
created and freed. That happens only at application start and finish not 
during run, as you require.

As a workaround, you can manually take care of the ptcwrapper object 
like this, in between closegraph and initgraph calls, but first ask 
yourself, do you really need this?

[...]
//close graph window
ptcgraph.Closegraph;

//manually terminate the ptcwrapper thread and free object
PTCWrapperObject.Terminate;
PTCWrapperObject.WaitFor;
PTCWrapperObject.Free;

//manually create the ptcwrapper thread
PTCWrapperObject := TPTCWrapperThread.Create;

//init graph windows as usual
ptcgraph.Initgraph(gd,gm,'');
[...]

Stefan

On 06/23/2017 11:20 AM, James Richters wrote:
> I ran into an unexpected issue with ptcgraph.  If I use closegraph, I
> cannot re-open a new ptcgraph window with Initgraph.  It looks like it
> opens the second graph window but then closes it immediately after.. my
> program is then appears to be locked up after this happens.. no errors,
> just locked up.   test program is below.  If I comment out ptcgraph and
> ptccrt and uncomment graph and wincrt, it works as expected.



More information about the fpc-pascal mailing list