From 282dedd0d5cace1002ce1528cdc1c059e71337d9 Mon Sep 17 00:00:00 2001 From: kimci86 Date: Mon, 14 Aug 2023 20:43:20 +0200 Subject: [PATCH] Fail to destruct used SoundBuffer also in release builds --- src/SFML/Audio/SoundBuffer.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/SFML/Audio/SoundBuffer.cpp b/src/SFML/Audio/SoundBuffer.cpp index 51bce993..616672f9 100644 --- a/src/SFML/Audio/SoundBuffer.cpp +++ b/src/SFML/Audio/SoundBuffer.cpp @@ -35,11 +35,10 @@ #include #include +#include #include #include -#include - #if defined(__APPLE__) #pragma GCC diagnostic ignored "-Wdeprecated-declarations" #endif @@ -70,7 +69,12 @@ SoundBuffer::SoundBuffer(const SoundBuffer& copy) : m_samples(copy.m_samples), m //////////////////////////////////////////////////////////// SoundBuffer::~SoundBuffer() { - assert(m_sounds.empty() && "sf::SoundBuffer must not be destructed while it is used by a sf::Sound"); + // Make sure no sound is attached to this buffer + if (!m_sounds.empty()) + { + err() << "Failed to destruct sound buffer because it is used by " << m_sounds.size() << " sound(s)" << std::endl; + std::terminate(); + } // Destroy the buffer if (m_buffer)