diff --git a/include/Font.hpp b/include/Font.hpp index b708c501..4d0908b4 100644 --- a/include/Font.hpp +++ b/include/Font.hpp @@ -101,7 +101,11 @@ class Font : public ::Font { } void Unload() { - UnloadFont(*this); + // Protect against calling UnloadFont() twice. + if (baseSize != 0) { + UnloadFont(*this); + baseSize = 0; + } } GETTERSETTER(int, BaseSize, baseSize) diff --git a/include/Sound.hpp b/include/Sound.hpp index f01abed1..4624aa64 100644 --- a/include/Sound.hpp +++ b/include/Sound.hpp @@ -95,7 +95,11 @@ class Sound : public ::Sound { * Unload sound */ inline void Unload() { - ::UnloadSound(*this); + // Protect against calling UnloadSound() twice. + if (frameCount != 0) { + ::UnloadSound(*this); + frameCount = 0; + } } /** diff --git a/include/TextureUnmanaged.hpp b/include/TextureUnmanaged.hpp index 76b3c457..d84049b2 100644 --- a/include/TextureUnmanaged.hpp +++ b/include/TextureUnmanaged.hpp @@ -132,7 +132,11 @@ class TextureUnmanaged : public ::Texture { * Unload texture from GPU memory (VRAM) */ inline void Unload() { - ::UnloadTexture(*this); + // Protect against calling UnloadTexture() twice. + if (id != 0) { + ::UnloadTexture(*this); + id = 0; + } } /** diff --git a/include/Wave.hpp b/include/Wave.hpp index bd3e2766..5628f489 100644 --- a/include/Wave.hpp +++ b/include/Wave.hpp @@ -161,6 +161,7 @@ class Wave : public ::Wave { * Unload wave data */ void Unload() { + // Protect against calling UnloadWave() twice. if (data != nullptr) { ::UnloadWave(*this); data = nullptr;