fix memory management problem
authorAlexander Alekhin <alexander.alekhin@itseez.com>
Wed, 29 Jan 2014 13:37:52 +0000 (17:37 +0400)
committerAlexander Alekhin <alexander.alekhin@itseez.com>
Wed, 29 Jan 2014 15:59:01 +0000 (19:59 +0400)
modules/core/include/opencv2/core/ocl.hpp
modules/core/src/ocl.cpp

index 850a2e6..3b790af 100644 (file)
@@ -561,6 +561,9 @@ public:
     explicit PlatformInfo2(void* id);
     ~PlatformInfo2();
 
+    PlatformInfo2(const PlatformInfo2& i);
+    PlatformInfo2& operator =(const PlatformInfo2& i);
+
     String name() const;
     String vendor() const;
     String version() const;
index 1a2714d..d1e13a8 100644 (file)
@@ -3707,6 +3707,26 @@ PlatformInfo2::~PlatformInfo2()
         p->release();
 }
 
+PlatformInfo2::PlatformInfo2(const PlatformInfo2& i)
+{
+    if (i.p)
+        i.p->addref();
+    this->p = i.p;
+}
+
+PlatformInfo2& PlatformInfo2::operator =(const PlatformInfo2& i)
+{
+    if (i.p != this->p)
+    {
+        if (i.p)
+            i.p->addref();
+        if (this->p)
+            this->p->release();
+        this->p = i.p;
+    }
+    return *this;
+}
+
 int PlatformInfo2::deviceNumber() const
 {
     return p ? (int)p->devices.size() : 0;