From e215fbd5b67f44957d85be11ec5f9ac9a0ff0f36 Mon Sep 17 00:00:00 2001 From: freezarite Date: Tue, 28 Jan 2025 19:40:14 +0100 Subject: [PATCH] instance changes in constructor and .cpp file for SoundManager --- include/SoundManager.h | 7 ++++++- src/SoundManager.cpp | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/SoundManager.h b/include/SoundManager.h index 922f67f..de7cd47 100644 --- a/include/SoundManager.h +++ b/include/SoundManager.h @@ -23,7 +23,12 @@ class SoundManager public: SoundManager() { - this_instance = this; + if (this_instance == nullptr) { + this_instance = this; + } + else { + throw std::runtime_error("SoundManager instance already exists!"); + } } ~SoundManager() { for (auto& it : this->sound_cache) { diff --git a/src/SoundManager.cpp b/src/SoundManager.cpp index 15475f4..fb61796 100644 --- a/src/SoundManager.cpp +++ b/src/SoundManager.cpp @@ -185,6 +185,8 @@ void SoundManager::addBackgroundMusic(const std::map