fix bug in Channel destructor for objects that were already moved

This commit is contained in:
Emiel Bruijntjes 2020-03-13 09:21:26 +01:00
parent f3ba779e67
commit 599764ebb8
1 changed files with 3 additions and 2 deletions

View File

@ -22,7 +22,7 @@ class Channel
private: private:
/** /**
* The implementation for the channel * The implementation for the channel
* @var std::unique_ptr<ChannelImpl> * @var std::shared_ptr<ChannelImpl>
*/ */
std::shared_ptr<ChannelImpl> _implementation; std::shared_ptr<ChannelImpl> _implementation;
@ -58,7 +58,8 @@ public:
virtual ~Channel() virtual ~Channel()
{ {
// close the channel (this will eventually destruct the channel) // close the channel (this will eventually destruct the channel)
_implementation->close(); // note that the channel may be in an invalid state in case it was moved, hence the "if"
if (_implementation) _implementation->close();
} }
/** /**