Revert changes concerning the smart pointer

This commit is contained in:
Tsuda kageyu
2013-04-17 22:54:56 +09:00
parent b6c9fb2da1
commit 1f4e06ea7c
26 changed files with 329 additions and 463 deletions

View File

@ -34,7 +34,7 @@
using namespace TagLib;
class ASF::Attribute::AttributePrivate
class ASF::Attribute::AttributePrivate : public RefCounter
{
public:
AttributePrivate()
@ -60,71 +60,77 @@ public:
////////////////////////////////////////////////////////////////////////////////
ASF::Attribute::Attribute()
: d(new AttributePrivate())
{
d = new AttributePrivate;
d->type = UnicodeType;
}
ASF::Attribute::Attribute(const ASF::Attribute &other)
: d(other.d)
{
d->ref();
}
ASF::Attribute &ASF::Attribute::operator=(const ASF::Attribute &other)
{
if(d->deref())
delete d;
d = other.d;
d->ref();
return *this;
}
ASF::Attribute::~Attribute()
{
if(d->deref())
delete d;
}
ASF::Attribute::Attribute(const String &value)
: d(new AttributePrivate())
{
d = new AttributePrivate;
d->type = UnicodeType;
d->stringValue = value;
}
ASF::Attribute::Attribute(const ByteVector &value)
: d(new AttributePrivate())
{
d = new AttributePrivate;
d->type = BytesType;
d->byteVectorValue = value;
}
ASF::Attribute::Attribute(const ASF::Picture &value)
: d(new AttributePrivate())
{
d = new AttributePrivate;
d->type = BytesType;
d->pictureValue = value;
}
ASF::Attribute::Attribute(unsigned int value)
: d(new AttributePrivate())
{
d = new AttributePrivate;
d->type = DWordType;
d->intValue = value;
}
ASF::Attribute::Attribute(unsigned long long value)
: d(new AttributePrivate())
{
d = new AttributePrivate;
d->type = QWordType;
d->longLongValue = value;
}
ASF::Attribute::Attribute(unsigned short value)
: d(new AttributePrivate())
{
d = new AttributePrivate;
d->type = WordType;
d->shortValue = value;
}
ASF::Attribute::Attribute(bool value)
: d(new AttributePrivate())
{
d = new AttributePrivate;
d->type = BoolType;
d->boolValue = value;
}

View File

@ -194,7 +194,7 @@ namespace TagLib
ByteVector render(const String &name, int kind = 0) const;
class AttributePrivate;
RefCountPtr<AttributePrivate> d;
AttributePrivate *d;
};
}

View File

@ -35,7 +35,7 @@
using namespace TagLib;
class ASF::Picture::PicturePrivate
class ASF::Picture::PicturePrivate : public RefCounter
{
public:
bool valid;
@ -50,18 +50,21 @@ public:
////////////////////////////////////////////////////////////////////////////////
ASF::Picture::Picture()
: d(new PicturePrivate())
{
d = new PicturePrivate();
d->valid = true;
}
ASF::Picture::Picture(const Picture& other)
: d(other.d)
{
d->ref();
}
ASF::Picture::~Picture()
{
if(d->deref())
delete d;
}
bool ASF::Picture::isValid() const
@ -118,7 +121,12 @@ int ASF::Picture::dataSize() const
ASF::Picture& ASF::Picture::operator=(const ASF::Picture& other)
{
d = other.d;
if(other.d != d) {
if(d->deref())
delete d;
d = other.d;
d->ref();
}
return *this;
}

View File

@ -207,10 +207,10 @@ namespace TagLib
static Picture fromInvalid();
friend class Attribute;
#endif
private:
class PicturePrivate;
RefCountPtr<PicturePrivate> d;
};
private:
class PicturePrivate;
PicturePrivate *d;
};
}
}