ocl: add try-catch for OpenCL device getter
authorAlexander Alekhin <alexander.alekhin@itseez.com>
Thu, 3 Jul 2014 08:18:19 +0000 (12:18 +0400)
committerAlexander Alekhin <alexander.alekhin@itseez.com>
Thu, 3 Jul 2014 08:18:19 +0000 (12:18 +0400)
modules/core/src/ocl.cpp

index 0b196d9..8ffd1d2 100644 (file)
@@ -1416,7 +1416,16 @@ bool useOpenCL()
 {
     CoreTLSData* data = coreTlsData.get();
     if( data->useOpenCL < 0 )
-        data->useOpenCL = (int)haveOpenCL() && Device::getDefault().ptr() != NULL;
+    {
+        try
+        {
+            data->useOpenCL = (int)haveOpenCL() && Device::getDefault().ptr() != NULL;
+        }
+        catch (...)
+        {
+            data->useOpenCL = 0;
+        }
+    }
     return data->useOpenCL > 0;
 }