Page 1 of 2

Application process is not terminated

Posted: Fri May 31, 2013 11:24 am
by 16665635
TeeChart V. 2013.0.1.0, C++ MFC application. TeeChart component is a member of a CView derived class and chart is created using .Create API function:

Code: Select all

.h
CTChart m_wndChart;

.cpp
m_wndChart.Create(_T(""), WS_CHILD|WS_VISIBLE, chartRect, this, ID_CHART)
When application is closed the application process is not terminated IF TeeChart component has been loaded into process. IF TeeChart component has NOT been loaded into process (i.e. no chart windows have been created or TeeChart component file has been renamed so that it cannot be loaded) application process is terminated normally. It does not matter if there are open chart windows or if all chart windows have been closed before closing the application.

Re: Application process is not terminated

Posted: Fri May 31, 2013 3:03 pm
by yeray
Hi,

Can you please arrange a simple example project we can run as-is to reproduce the problem here?
Thanks in advance.

Re: Application process is not terminated

Posted: Tue Jun 04, 2013 9:15 am
by 16665635
Unfortunately we cannot reproduce this problem using a simple test program. Here is a call stack from our application:
Call stack.PNG
Call stack.PNG (303.72 KiB) Viewed 35879 times
As we do not have symbols for TeeChart we cannot look any further to the problem ourselves. If you have any suggestions how to proceed feel free to contact privately by email as we cannot provide any more specific information in a public forum.

Re: Application process is not terminated

Posted: Tue Jun 04, 2013 11:33 am
by 16665635
OK. We found the reason for the deadlock. TeeChart calls GdiplusStartup and GdiPlusShutdown which it should not do. Here is a Remark section from MSDN for GdiplusStartup:
Remarks

Do not call GdiplusStartup or GdiplusShutdown in DllMain or in any function that is called by DllMain. If you want to create a DLL that uses GDI+, you should use one of the following techniques to initialize GDI+:
- Require your clients to call GdiplusStartup before they call the functions in your DLL and to call GdiplusShutdown when they have finished using your DLL.
- Export your own startup function that calls GdiplusStartup and your own shutdown function that calls GdiplusShutdown. Require your clients to call your startup function before they call other functions in your DLL and to call your shutdown function when they have finished using your DLL.
- Call GdiplusStartup and GdiplusShutdown in each of your functions that make GDI+ calls.
An example program included. If you comment out GdiplusShutdown call from MainFrm.cpp line 69 process is terminated correctly otherwise it is not terminated. The correct solution is that TeeChart does not call these functions but implements some of the mechanisms outlined in the remarks section above.

Re: Application process is not terminated

Posted: Tue Jun 04, 2013 2:28 pm
by yeray
Hello,

I've reproduced the problem.
I see you are customer since TeeChart ActiveX v6, isn't it? So assume it works fine in older versions. Have you identified the last version where it worked fine?

Re: Application process is not terminated

Posted: Wed Jun 05, 2013 6:16 am
by 16665635
TeeChart ActiveX v 8. 2012.0.0.9 does not work as well as 2013.0.1.0. We have not used anything between v 8 and 2012.0.0.9.

Re: Application process is not terminated

Posted: Wed Jun 05, 2013 6:20 am
by 16665635
Any chance you get this fixed fast? We have a deadline approaching and need to rollback to v 8 if this is not fixed in a week or two. Thanks.

Re: Application process is not terminated

Posted: Wed Jun 05, 2013 10:54 am
by yeray
Hello Tero,

We are currently investigating what change in v2013.0.1.0 could affect this. It seems to work fine in v2012.0.0.9.
TeeChart moved the default Canvas from GDI to GDI+ in this version. So you could try to disable GDI+ to see if it works better.

Re: Application process is not terminated

Posted: Thu Jun 06, 2013 7:42 am
by yeray
Update with some information the customer gave us through mail (tell us if you don't want to make it public here):
jhameenniemi wrote:actually we do not use GDI+ rendering because TeeChart 2013.0.1.0. has some rendering bugs if using GDI+ so we switched back to GDI rendering:

Code: Select all

m_wndChart.GetAspect().GetGDIPlus().SetActive(FALSE); // disable GDI+ rendering (defaults to enabled in V.2013)
so no, it does not solve anything. Our products use GDI+ and some GDI+ calls are made in .dll:s so we need to call GdiplusStartup in application’s InitInstance() and GdiplusShutdown in ExitInstance() because we know for sure that some of them do not call these functions before using GDI+ calls.
We are investigating what's happening here (TA05016588).
However, I'm afraid I can't tell you if this is going to be fixed imminently or in how many time.

Re: Application process is not terminated

Posted: Thu Jun 06, 2013 8:23 am
by 16665635
Yeray,

you are correct. 2012.0.0.9 works OK. I did not realize that 2012.0.0.9 and 2013.0.1.0 cannot co-exist in the same machine which I think was a natural assumption because file names are different (TeeChart2012.ocx vs. TeeChart2013.ocx).

Re: Application process is not terminated

Posted: Thu Jun 06, 2013 1:34 pm
by yeray
Hi,

Right, both versions use the same GUID so it's easier to upgrade your applications.

Re: Application process is not terminated

Posted: Tue Jun 11, 2013 9:26 am
by Marc
Hello,

Thanks for the detailed problem submission and observations about GDIPlusStartup/Shutdown. With the change to GDI+ as default rendering mode we had not sufficiently envisaged that TeeChart might be used in this way in a container using GDIPlus. Looking to resolve the problem, we need a solution that permits us to maintain TeeChart's GDI+ render as default render mode and allows a developer to override it, disabling GDI+ and shutting it down without consequence for the container application....

Fortunately nesting GDIPlusStartup/Shutdown is a technically workable option and tests we've made to follow nested GdiPlusToken values confirms that to be the case. Our tests have also confirmed that if an unload is made out of nest sequence a problem can occur. That seems to have been the case in the version of TeeChart AX that you have been using.

We are making a test version available that offers nestable shutdown of TeeChart's GDIPlus. We hope that will be a useable option for you. Your feedback will be appreciated.

With thanks.
Regards,
Marc Meumann

Re: Application process is not terminated

Posted: Thu Nov 14, 2013 8:07 am
by 16665635
Any plans to make this fix permanent and included in maintenance release builds? It is a pita to ask special .ocx version for every maintenance release.

Re: Application process is not terminated

Posted: Thu Nov 14, 2013 8:23 am
by Marc
Hello,

Yes, we fully intend that the GDIShutdown feature form a part of the core product. It was to be included in the last build but due to a technical hitch it has been postponed for the next build that we expect to make available imminently. Apologies for the inconvenience caused.

Regards,
Marc Meumann

Re: Application process is not terminated

Posted: Mon Sep 29, 2014 7:09 am
by 16665635
Downloaded the lastest release and surprise surprise GDI+ intialization bug is once again back. Please, fix it. Thank you.