From d99b117a60e4331043db1050abdabf172b34855d Mon Sep 17 00:00:00 2001 From: Emiel Bruijntjes Date: Mon, 4 Aug 2014 13:44:17 +0200 Subject: [PATCH] fixed bug in channel.get() calls --- src/deferredget.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/deferredget.cpp b/src/deferredget.cpp index 68c13832..0cf24a91 100644 --- a/src/deferredget.cpp +++ b/src/deferredget.cpp @@ -32,14 +32,17 @@ Deferred *DeferredGet::reportSuccess(uint32_t messageCount) const // we now know the name, so we can install the message callback on the channel _channel->install("", [channel, messageCallback, finalizeCallback](const Message &message, uint64_t deliveryTag, bool redelivered) { - // we can remove the callback now from the channel - channel->uninstall(""); - + // install a monitor to deal with the case that the channel is removed + Monitor monitor(channel); + // call the callbacks if (messageCallback) messageCallback(message, deliveryTag, redelivered); // call the finalize callback if (finalizeCallback) finalizeCallback(); + + // we can remove the callback now from the channel + if (monitor.valid()) channel->uninstall(""); }); // return next object