File tree Expand file tree Collapse file tree 4 files changed +16
-3
lines changed Expand file tree Collapse file tree 4 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -101,7 +101,11 @@ class Font : public ::Font {
101101 }
102102
103103 void Unload () {
104- UnloadFont (*this );
104+ // Protect against calling UnloadFont() twice.
105+ if (baseSize != 0 ) {
106+ UnloadFont (*this );
107+ baseSize = 0 ;
108+ }
105109 }
106110
107111 GETTERSETTER (int , BaseSize, baseSize)
Original file line number Diff line number Diff line change @@ -95,7 +95,11 @@ class Sound : public ::Sound {
9595 * Unload sound
9696 */
9797 inline void Unload () {
98- ::UnloadSound (*this );
98+ // Protect against calling UnloadSound() twice.
99+ if (frameCount != 0 ) {
100+ ::UnloadSound (*this );
101+ frameCount = 0 ;
102+ }
99103 }
100104
101105 /* *
Original file line number Diff line number Diff line change @@ -132,7 +132,11 @@ class TextureUnmanaged : public ::Texture {
132132 * Unload texture from GPU memory (VRAM)
133133 */
134134 inline void Unload () {
135- ::UnloadTexture (*this );
135+ // Protect against calling UnloadTexture() twice.
136+ if (id != 0 ) {
137+ ::UnloadTexture (*this );
138+ id = 0 ;
139+ }
136140 }
137141
138142 /* *
Original file line number Diff line number Diff line change @@ -161,6 +161,7 @@ class Wave : public ::Wave {
161161 * Unload wave data
162162 */
163163 void Unload () {
164+ // Protect against calling UnloadWave() twice.
164165 if (data != nullptr ) {
165166 ::UnloadWave (*this );
166167 data = nullptr ;
You can’t perform that action at this time.
0 commit comments