From cd67ed98148ec088032c6065db4fd0070f47584c Mon Sep 17 00:00:00 2001 From: Gabriel Ferreira Date: Mon, 13 Jan 2025 20:39:49 +0100 Subject: [PATCH] spectrum: Change order of disposal for ThreeGppPropagationLossModel --- src/spectrum/model/spectrum-channel.cc | 9 +++++++++ .../model/three-gpp-spectrum-propagation-loss-model.cc | 1 - 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/spectrum/model/spectrum-channel.cc b/src/spectrum/model/spectrum-channel.cc index 9abe4b1ce1..229285310e 100644 --- a/src/spectrum/model/spectrum-channel.cc +++ b/src/spectrum/model/spectrum-channel.cc @@ -33,9 +33,18 @@ void SpectrumChannel::DoDispose() { NS_LOG_FUNCTION(this); + + // Any propagation model that holds a pointer + // back to the spectrum channel should not call Dispose() + // of its channel pointer, or else a loop may occur. m_propagationLoss = nullptr; m_propagationDelay = nullptr; m_spectrumPropagationLoss = nullptr; + if (m_phasedArraySpectrumPropagationLoss) + { + m_phasedArraySpectrumPropagationLoss->Dispose(); + } + m_phasedArraySpectrumPropagationLoss = nullptr; } TypeId diff --git a/src/spectrum/model/three-gpp-spectrum-propagation-loss-model.cc b/src/spectrum/model/three-gpp-spectrum-propagation-loss-model.cc index 00dd1f928d..7bba9ac894 100644 --- a/src/spectrum/model/three-gpp-spectrum-propagation-loss-model.cc +++ b/src/spectrum/model/three-gpp-spectrum-propagation-loss-model.cc @@ -44,7 +44,6 @@ void ThreeGppSpectrumPropagationLossModel::DoDispose() { m_longTermMap.clear(); - m_channelModel->Dispose(); m_channelModel = nullptr; }