From 0e14b54b6d4c74fbd4d7f4ec4cfd629a0667a7cd Mon Sep 17 00:00:00 2001 From: orignal Date: Fri, 25 Nov 2016 22:36:35 -0500 Subject: [PATCH] break circular reference --- Destination.cpp | 15 +++++++++++---- Streaming.h | 1 + 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Destination.cpp b/Destination.cpp index 7b2e896d..66fb4cef 100644 --- a/Destination.cpp +++ b/Destination.cpp @@ -700,13 +700,20 @@ namespace client { m_ReadyChecker.cancel(); m_StreamingDestination->Stop (); + m_StreamingDestination->SetOwner (nullptr); m_StreamingDestination = nullptr; for (auto& it: m_StreamingDestinationsByPorts) + { it.second->Stop (); - if(m_DatagramDestination) - delete m_DatagramDestination; - m_DatagramDestination = nullptr; - return true; + it.second->SetOwner (nullptr); + } + m_StreamingDestinationsByPorts.clear (); + if (m_DatagramDestination) + { + delete m_DatagramDestination; + m_DatagramDestination = nullptr; + } + return true; } else return false; diff --git a/Streaming.h b/Streaming.h index e4a1562c..65a8d8b4 100644 --- a/Streaming.h +++ b/Streaming.h @@ -224,6 +224,7 @@ namespace stream void ResetAcceptor (); bool IsAcceptorSet () const { return m_Acceptor != nullptr; }; std::shared_ptr GetOwner () const { return m_Owner; }; + void SetOwner (std::shared_ptr owner) { m_Owner = owner; }; uint16_t GetLocalPort () const { return m_LocalPort; }; void HandleDataMessagePayload (const uint8_t * buf, size_t len);