OCCTProxy class cleanup crashes

I've taken the OCCTProxy example (a C++ proxy class callable from CSharp) and converted it into a DLL interface that exposes a plain C interface for the viewer. The goal is to use OCCT's viewer from an older application that can only call C libraries, and that goal is working.

The OCCTProxy example does not have any destructor or cleanup. So I've attempted to implement one, based on allocations that happen in InitViewer(). But something is crashing. When I close my application's form (which calls the the destructor), the application crashes.

So my question is where to find good examples of how/when to cleanup all the instantiated in InitViewer(), and in what order to delete those classes safely.

Attached is the main source of my CProxy class and the extern'd C calls that wrap it.

gariann's picture

Replying to my own post with other possibly pertinent details: using Visual Studio 2013, and OCCT 6.7.1, all compiled in a 32-bit build environment.