Commit 7a575d49 authored by Jan Hambrecht's avatar Jan Hambrecht

use QAtomicInt for refcounting as suggested by Thomas


svn path=/trunk/koffice/; revision=820294
parent 8453dc4f
......@@ -94,14 +94,11 @@ public:
manager->remove(me);
delete userData;
delete appData;
if(border) {
border->removeUser();
if(border->useCount() == 0)
delete border;
}
if( shadow && shadow->removeUser() == 0 )
if( border && ! border->removeUser() )
delete border;
if( shadow && ! shadow->removeUser() )
delete shadow;
if( fill && fill->removeUser() == 0 )
if( fill && ! fill->removeUser() )
delete fill;
qDeleteAll( eventActions );
}
......
......@@ -19,11 +19,13 @@
#include "KoShapeBackground.h"
#include <QtCore/QAtomicInt>
class KoShapeBackground::Private
{
public:
Private() : refCount(0) { }
int refCount;
QAtomicInt refCount;
};
KoShapeBackground::KoShapeBackground()
......@@ -43,12 +45,12 @@ bool KoShapeBackground::hasTransparency()
void KoShapeBackground::addUser()
{
d->refCount++;
d->refCount.ref();
}
int KoShapeBackground::removeUser()
bool KoShapeBackground::removeUser()
{
return --d->refCount;
return d->refCount.deref();
}
int KoShapeBackground::useCount() const
......
......@@ -54,7 +54,7 @@ public:
/// refcounting
void addUser();
/// refcounting
int removeUser();
bool removeUser();
/// refcounting
int useCount() const;
......
......@@ -22,7 +22,7 @@
class KoShapeBorderModel::Private {
public:
Private() : refCount(0) { }
int refCount;
QAtomicInt refCount;
};
KoShapeBorderModel::KoShapeBorderModel()
......@@ -42,11 +42,11 @@ KoInsets KoShapeBorderModel::borderInsets(const KoShape *shape) {
}
void KoShapeBorderModel::addUser() {
d->refCount++;
d->refCount.ref();
}
int KoShapeBorderModel::removeUser() {
return --d->refCount;
bool KoShapeBorderModel::removeUser() {
return d->refCount.deref();
}
int KoShapeBorderModel::useCount() const {
......
......@@ -83,7 +83,7 @@ public:
/// refcounting
void addUser();
/// refcounting
int removeUser();
bool removeUser();
/// refcounting
int useCount() const;
......
......@@ -24,6 +24,7 @@
#include "KoPathShape.h"
#include <KoGenStyle.h>
#include <QtGui/QPainter>
#include <QtCore/QAtomicInt>
class KoShapeShadow::Private
{
......@@ -35,7 +36,7 @@ public:
QPointF offset;
QColor color;
bool visible;
int refCount;
QAtomicInt refCount;
};
KoShapeShadow::KoShapeShadow()
......@@ -127,12 +128,12 @@ void KoShapeShadow::insets( const KoShape *shape, KoInsets &insets )
void KoShapeShadow::addUser()
{
d->refCount++;
d->refCount.ref();
}
int KoShapeShadow::removeUser()
bool KoShapeShadow::removeUser()
{
return --d->refCount;
return d->refCount.deref();
}
int KoShapeShadow::useCount() const
......
......@@ -83,7 +83,7 @@ public:
/// Increase reference counter
void addUser();
/// Decrease reference counter
int removeUser();
bool removeUser();
/// Return reference counter
int useCount() const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment