Skip to content
Snippets Groups Projects
Verified Commit 8c439fa7 authored by Clayton Craft's avatar Clayton Craft
Browse files

main: move TTF_Init from keyboard::makeKeyboard (MR 145)

Other objects use TTF_* too, so initializing it in the keyboard object
could introduce some race condition (though I've never seen one first
hand...)

It's still good to do it in a central place. This also calls TTF_Quit()
to clean up.
parent cdc37afe
No related branches found
No related tags found
No related merge requests found
......@@ -325,11 +325,6 @@ SDL_Surface *Keyboard::makeKeyboard(KeyboardLayer *layer, bool isHighlighted) co
rowHeight = keyboardHeight / rowCount;
}
if (TTF_Init() == -1) {
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "TTF_Init: %s", TTF_GetError());
return nullptr;
}
TTF_Font *font = TTF_OpenFont(config->keyboardFont.c_str(), config->keyboardFontSize);
if (!font) {
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "TTF_OpenFont: %s", TTF_GetError());
......
......@@ -158,6 +158,11 @@ int main(int argc, char **args)
exit(EXIT_FAILURE);
}
if (TTF_Init() == -1) {
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "TTF_Init: %s", TTF_GetError());
exit(EXIT_FAILURE);
}
int keyboardHeight = HEIGHT / 3 * 2;
if (HEIGHT > WIDTH) {
// Keyboard height is screen width / max number of keys per row * rows
......@@ -480,6 +485,8 @@ QUIT:
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(display);
TTF_Quit();
SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_TIMER | SDL_INIT_HAPTIC);
if (opts.keyscript) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment