fix memory management problem

This commit is contained in:
Alexander Alekhin 2014-01-29 17:37:52 +04:00
parent 5474935a81
commit f91f55927e
2 changed files with 23 additions and 0 deletions

View 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;

View 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;