From f1059fbd7f64bf0ae8324e3e6bed9ce28f593b23 Mon Sep 17 00:00:00 2001 From: Dario Casalinuovo Date: Thu, 28 Jan 2016 23:27:38 +0100 Subject: [PATCH] BSoundPlayer: Release the node instead to delete * It's a bad idea to delete directly a node. There are some mechanisms behind that might break if not used correctly. * May help with #12606. --- src/kits/media/SoundPlayer.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/kits/media/SoundPlayer.cpp b/src/kits/media/SoundPlayer.cpp index 42db720bca..1b57fe9046 100644 --- a/src/kits/media/SoundPlayer.cpp +++ b/src/kits/media/SoundPlayer.cpp @@ -143,8 +143,17 @@ cleanup: // We do not call BMediaRoster::ReleaseNode(), since // the player was created by using "new". We could // call BMediaRoster::UnregisterNode(), but this is - // supposed to be done by BMediaNode destructor automatically - delete fPlayerNode; + // supposed to be done by BMediaNode destructor automatically. + + // The node is deleted by the Release() when ref count reach 0. + // Since we are the sole owners, and no one acquired it + // this should be the case. The Quit() synchronization + // is handled by the DeleteHook inheritance. + // NOTE: this might be crucial when using a BMediaEventLooper. + if (fPlayerNode->Release() != NULL) { + TRACE("BSoundPlayer::~BSoundPlayer: Error the producer node " + "appears to be acquired by someone else than us!"); + } // do not delete fVolumeSlider, it belongs to the parameter web delete fParameterWeb;