Fix memory leak

This commit is contained in:
Martijn Otto 2014-05-06 16:49:43 +02:00
parent 7084d49b13
commit ca8a39ea45
1 changed files with 17 additions and 12 deletions

View File

@ -72,11 +72,11 @@ protected:
// execute callbacks if registered // execute callbacks if registered
if (_successCallback) _successCallback(); if (_successCallback) _successCallback();
if (_finalizeCallback) _finalizeCallback(); if (_finalizeCallback) _finalizeCallback();
// return the next deferred result // return the next deferred result
return _next; return _next;
} }
/** /**
* Report success for queue declared messages * Report success for queue declared messages
* @param name Name of the new queue * @param name Name of the new queue
@ -89,7 +89,7 @@ protected:
// this is the same as a regular success message // this is the same as a regular success message
return reportSuccess(); return reportSuccess();
} }
/** /**
* Report success for frames that report delete operations * Report success for frames that report delete operations
* @param messagecount Number of messages that were deleted * @param messagecount Number of messages that were deleted
@ -100,7 +100,7 @@ protected:
// this is the same as a regular success message // this is the same as a regular success message
return reportSuccess(); return reportSuccess();
} }
/** /**
* Report success for frames that report cancel operations * Report success for frames that report cancel operations
* @param name Consumer tag that is cancelled * @param name Consumer tag that is cancelled
@ -117,15 +117,15 @@ protected:
* @param error Description of the error that occured * @param error Description of the error that occured
* @return Deferred Next deferred result * @return Deferred Next deferred result
*/ */
Deferred *reportError(const char *error) Deferred *reportError(const char *error)
{ {
// from this moment on the object should be listed as failed // from this moment on the object should be listed as failed
_failed = true; _failed = true;
// execute callbacks if registered // execute callbacks if registered
if (_errorCallback) _errorCallback(error); if (_errorCallback) _errorCallback(error);
if (_finalizeCallback) _finalizeCallback(); if (_finalizeCallback) _finalizeCallback();
// return the next deferred result // return the next deferred result
return _next; return _next;
} }
@ -146,7 +146,7 @@ protected:
*/ */
friend class ChannelImpl; friend class ChannelImpl;
friend class Callbacks; friend class Callbacks;
protected: protected:
/** /**
* Protected constructor that can only be called * Protected constructor that can only be called
@ -163,6 +163,11 @@ public:
Deferred(const Deferred &that) = delete; Deferred(const Deferred &that) = delete;
Deferred(Deferred &&that) = delete; Deferred(Deferred &&that) = delete;
/**
* Destructor
*/
virtual ~Deferred() {}
/** /**
* Cast to a boolean * Cast to a boolean
*/ */
@ -186,7 +191,7 @@ public:
{ {
// store callback // store callback
_successCallback = callback; _successCallback = callback;
// allow chaining // allow chaining
return *this; return *this;
} }
@ -208,7 +213,7 @@ public:
// if the object is already in a failed state, we call the callback right away // if the object is already in a failed state, we call the callback right away
if (_failed) callback("Frame could not be sent"); if (_failed) callback("Frame could not be sent");
// allow chaining // allow chaining
return *this; return *this;
} }
@ -232,10 +237,10 @@ public:
{ {
// store callback // store callback
_finalizeCallback = callback; _finalizeCallback = callback;
// if the object is already in a failed state, we call the callback right away // if the object is already in a failed state, we call the callback right away
if (_failed) callback(); if (_failed) callback();
// allow chaining // allow chaining
return *this; return *this;
} }