Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion include/Font.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion include/Sound.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

/**
Expand Down
6 changes: 5 additions & 1 deletion include/TextureUnmanaged.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

/**
Expand Down
1 change: 1 addition & 0 deletions include/Wave.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down