Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Oct 31, 2014
1 parent cbfb157 commit 0e216a3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 38 deletions.
3 changes: 1 addition & 2 deletions doomsday/client/src/ui/widgets/savedsessionmenuwidget.cpp
Expand Up @@ -145,8 +145,7 @@ DENG_GUI_PIMPL(SavedSessionMenuWidget)
}
};

Instance(Public *i)
: Base(i)
Instance(Public *i) : Base(i)
{
App::app().audienceForStartupComplete() += this;
game::Session::savedIndex().audienceForAvailabilityUpdate() += this;
Expand Down
15 changes: 0 additions & 15 deletions doomsday/libcore/include/de/data/counted.h
Expand Up @@ -40,19 +40,6 @@ class DENG2_PUBLIC Counted
*/
Counted();

/**
* Converts the reference-counted object to a delegated one. Delegated
* reference counting means that references held to and released from the
* object actually are held to/released from the delegate target.
*
* @note The reference count of this object is ignored (set to zero). This
* object must then be deleted directly rathen than via releasing (as
* releasing would actually attempt to release the delegate target).
*
* @param delegate Delegate target.
*/
void setDelegate(Counted const *delegate);

/**
* Acquires a reference to the reference-counted object. Use the
* template to get the correct type of pointer from a derived class.
Expand Down Expand Up @@ -102,8 +89,6 @@ class DENG2_PUBLIC Counted
mutable dint _refCount;

private:
Counted const *_delegate;

template <typename Type>
friend Type *refless(Type *counted);

Expand Down
28 changes: 7 additions & 21 deletions doomsday/libcore/src/data/counted.cpp
Expand Up @@ -25,53 +25,39 @@ namespace de {
int Counted::totalCount = 0; ///< Should return back to zero when program ends.
#endif

Counted::Counted() : _refCount(1), _delegate(0)
Counted::Counted() : _refCount(1)
{
#ifdef DENG2_DEBUG
totalCount++;
#endif
}

void Counted::setDelegate(Counted const *delegate)
{
DENG2_ASSERT(_delegate == 0);
DENG2_ASSERT(_refCount == 1);

_delegate = delegate;
_refCount = 0; // won't be released any more
}

Counted::~Counted()
{
#ifdef DENG2_DEBUG
totalCount--;
#endif
//qDebug() << "~Counted" << this << typeid(*this).name() << "refCount:" << _refCount;

DENG2_ASSERT(!_delegate || _delegate->_refCount == 0);
DENG2_ASSERT(_refCount == 0);
}

void Counted::release() const
{
Counted const *c = (!_delegate? this : _delegate);

//qDebug() << "Counted" << c << typeid(*c).name() << "ref dec'd to" << c->_refCount - 1;

DENG2_ASSERT(c->_refCount > 0);
if(!--c->_refCount)
DENG2_ASSERT(_refCount > 0);
if(!--_refCount)
{
delete c;
delete this;
}
}

void Counted::addRef(dint count) const
{
Counted const *c = (!_delegate? this : _delegate);

DENG2_ASSERT(c->_refCount >= 0);
c->_refCount += count;
DENG2_ASSERT(c->_refCount >= 0);
DENG2_ASSERT(_refCount >= 0);
_refCount += count;
DENG2_ASSERT(_refCount >= 0);
}

} // namespace de

0 comments on commit 0e216a3

Please sign in to comment.