Merge pull request #4136 from alalek:fix_matallocator_destruction

pull/4146/head
Vadim Pisarevsky 10 years ago
commit bd90425f71
  1. 8
      modules/core/src/matrix.cpp
  2. 9
      modules/core/src/ocl.cpp

@ -222,10 +222,14 @@ public:
} }
}; };
static StdMatAllocator *mat_allocator = NULL;
MatAllocator* Mat::getStdAllocator() MatAllocator* Mat::getStdAllocator()
{ {
static StdMatAllocator allocator; if (mat_allocator == NULL)
return &allocator; {
mat_allocator = new StdMatAllocator();
}
return mat_allocator;
} }
void swap( Mat& a, Mat& b ) void swap( Mat& a, Mat& b )

@ -5237,10 +5237,15 @@ public:
MatAllocator* matStdAllocator; MatAllocator* matStdAllocator;
}; };
// This line should not force OpenCL runtime initialization! (don't put "new OpenCLAllocator()" here)
static MatAllocator *ocl_allocator = NULL;
MatAllocator* getOpenCLAllocator() MatAllocator* getOpenCLAllocator()
{ {
static MatAllocator * allocator = new OpenCLAllocator(); if (ocl_allocator == NULL)
return allocator; {
ocl_allocator = new OpenCLAllocator();
}
return ocl_allocator;
} }
}} // namespace cv::ocl }} // namespace cv::ocl

Loading…
Cancel
Save