Skip to content

Commit 20eb733

Browse files
committed
bugfix: Arreglo el segmentation fault
La biblioteca de fonts de sdl se estaba destruyendo antes de algunos componentes que todavia la necesitaban. Por ahora la hago static para que dure todo el programa.
1 parent e799fe5 commit 20eb733

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/graphics/gameview.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Gameview::Gameview(std::map<int, std::unique_ptr<RenderableObject>> &gameObjects) :
1010
sdl(SDL_INIT_VIDEO | SDL_INIT_AUDIO),
11-
ttf(),
11+
//ttf(),
1212
window("Game", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
1313
1280, 720,
1414
SDL_WINDOW_RESIZABLE),

src/graphics/gameview.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
class Gameview {
1414
SDL2pp::SDL sdl;
1515

16-
SDL2pp::SDLTTF ttf;
16+
// SDL2pp::SDLTTF ttf;
1717

1818
SDL2pp::Window window;
1919

src/main.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ int main(int argc, char *argv[])
6464
}
6565
std::cout<<"start playing"<<std::endl;
6666

67+
// TODO: probar algo mejor
68+
/*
69+
* Antes tenia el ttf en el gameview pero se destruia antes que el textureloader,
70+
* entonces el texture loader no podia destruir fonts, porque la clase Font
71+
* depende de que la libreria SDLTTF este inicializada.
72+
* Un quilombo.
73+
* La hago static para que dure durante el programa.
74+
*/
75+
static SDL2pp::SDLTTF ttf;
6776
GameviewConfigurationsLoader &configs = GameviewConfigurationsLoader::getInstance();
6877
std::map<int, std::unique_ptr<RenderableObject>> objects;
6978
Gameview view(objects);

0 commit comments

Comments
 (0)