From 6b9f74ae84e88be0a86df780ee9415036774ce9a Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Sun, 6 Oct 2013 14:34:36 +0400 Subject: [PATCH] ocl: fix cleanup on Windows platform (for clAmdBlas/clAmdFft) --- modules/ocl/src/cl_context.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/ocl/src/cl_context.cpp b/modules/ocl/src/cl_context.cpp index f8120a0fbb..900a5eb092 100644 --- a/modules/ocl/src/cl_context.cpp +++ b/modules/ocl/src/cl_context.cpp @@ -724,7 +724,14 @@ bool supportsFeature(FEATURE_TYPE featureType) struct __Module { __Module() { /* moved to Context::getContext(): initializeOpenCLDevices(); */ } - ~__Module() { ContextImpl::cleanupContext(); } + ~__Module() + { +#if defined(WIN32) && defined(CVAPI_EXPORTS) + // nothing, see DllMain +#else + ContextImpl::cleanupContext(); +#endif + } }; static __Module __module; @@ -742,6 +749,7 @@ BOOL WINAPI DllMain(HINSTANCE /*hInst*/, DWORD fdwReason, LPVOID lpReserved) { if (lpReserved != NULL) // called after ExitProcess() call cv::ocl::__termination = true; + cv::ocl::ContextImpl::cleanupContext(); } return TRUE; }