diff --git a/changelog.txt b/changelog.txt index 2bed2e298..81d1f393c 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,7 @@ October 25 -Added gameImageNotFound tag for an image to display if a game image is not found/defined. -Fixed keyboard not skipping joystick input configuration. +-Fixed a nasty crash bug with sounds. Always initialize your variables, kids! October 17 -Added GuiAnimation class which animates its children. diff --git a/src/Font.h b/src/Font.h index 2d08f0ea7..af1ad6d5b 100644 --- a/src/Font.h +++ b/src/Font.h @@ -8,7 +8,9 @@ #include #include FT_FREETYPE_H -//A TrueType Font renderer that uses FreeType and OpenGL. initLibrary() MUST be called before using it. +//A TrueType Font renderer that uses FreeType and OpenGL. +//Subclass of GuiComponent to catch ::onInit and ::onDeinit. +//The library is automatically initialized when it's needed. class Font : GuiComponent { public: diff --git a/src/Renderer_draw_gl.cpp b/src/Renderer_draw_gl.cpp index c19963e7f..401b4aaa6 100644 --- a/src/Renderer_draw_gl.cpp +++ b/src/Renderer_draw_gl.cpp @@ -59,8 +59,7 @@ namespace Renderer { Font* fonts[3] = {NULL, NULL, NULL}; - //this is never really used, but is here "just in case" - void unloadFonts() + /*void unloadFonts() { std::cout << "unloading fonts..."; @@ -73,12 +72,13 @@ namespace Renderer { loadedFonts = false; std::cout << "done.\n"; - } + }*/ + //creates the default fonts (which shouldn't ever be deleted) void loadFonts() { if(loadedFonts) - unloadFonts(); + return; std::cout << "loading fonts..."; diff --git a/src/Renderer_init_rpi.cpp b/src/Renderer_init_rpi.cpp index a4c66539d..138aac4df 100644 --- a/src/Renderer_init_rpi.cpp +++ b/src/Renderer_init_rpi.cpp @@ -199,8 +199,6 @@ namespace Renderer if(!createdSurface) return false; - Font::initLibrary(); - glViewport(0, 0, display_width, display_height); glOrthof(0, display_width, display_height, 0, -1.0, 1.0); glClearColor(1.0f, 1.0f, 1.0f, 1.0f); @@ -210,12 +208,9 @@ namespace Renderer return true; } - void unloadFonts(); //defined in Renderer_draw_gl.cpp void deinit() { onDeinit(); - - //unloadFonts(); destroySurface(); } }; diff --git a/src/Renderer_init_sdlgl.cpp b/src/Renderer_init_sdlgl.cpp index 13d3d4b97..d560e8480 100644 --- a/src/Renderer_init_sdlgl.cpp +++ b/src/Renderer_init_sdlgl.cpp @@ -79,8 +79,6 @@ namespace Renderer if(!createdSurface) return false; - //Font::initLibrary(); - glViewport(0, 0, display_width, display_height); glOrtho(0, display_width, display_height, 0, -1.0, 1.0); glClearColor(1.0f, 1.0f, 1.0f, 1.0f); @@ -90,12 +88,9 @@ namespace Renderer return true; } - void unloadFonts(); //defined in Renderer_draw_gl.cpp void deinit() { onDeinit(); - - //unloadFonts(); destroySurface(); } }; diff --git a/src/Sound.cpp b/src/Sound.cpp index 904699292..a8f0a260e 100644 --- a/src/Sound.cpp +++ b/src/Sound.cpp @@ -5,6 +5,7 @@ Sound::Sound(std::string path) { mSound = NULL; + mChannel = -1; AudioManager::registerSound(this);