From a7c14f595482426ea7200cde3c5c6b98ca813a7e Mon Sep 17 00:00:00 2001 From: Lars Mueller Date: Fri, 10 Jan 2025 21:24:15 +0100 Subject: [PATCH] rely on FT_Library being a pointer --- src/irrlicht_changes/CGUITTFont.cpp | 13 ++++++------- src/irrlicht_changes/CGUITTFont.h | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/irrlicht_changes/CGUITTFont.cpp b/src/irrlicht_changes/CGUITTFont.cpp index 100b925607d38..4c07da140a58a 100644 --- a/src/irrlicht_changes/CGUITTFont.cpp +++ b/src/irrlicht_changes/CGUITTFont.cpp @@ -42,7 +42,6 @@ #include #include -#include namespace irr { @@ -50,18 +49,18 @@ namespace gui { std::map SGUITTFace::faces; -std::optional SGUITTFace::freetype_library; -std::size_t SGUITTFace::n_faces; +FT_Library SGUITTFace::freetype_library = nullptr; +std::size_t SGUITTFace::n_faces = 0; FT_Library SGUITTFace::getFreeTypeLibrary() { if (freetype_library) - return *freetype_library; + return freetype_library; FT_Library ft; if (FT_Init_FreeType(&ft)) FATAL_ERROR("initializing freetype failed"); freetype_library = ft; - return *freetype_library; + return freetype_library; } SGUITTFace::SGUITTFace(std::string &&buffer) : face_buffer(std::move(buffer)) @@ -77,8 +76,8 @@ SGUITTFace::~SGUITTFace() // If there are no more faces referenced by FreeType, clean up. if (n_faces == 0) { assert(freetype_library); - FT_Done_FreeType(*freetype_library); - freetype_library = std::nullopt; + FT_Done_FreeType(freetype_library); + freetype_library = nullptr; } } diff --git a/src/irrlicht_changes/CGUITTFont.h b/src/irrlicht_changes/CGUITTFont.h index 671bc38e0ae12..ffdd6a6caf434 100644 --- a/src/irrlicht_changes/CGUITTFont.h +++ b/src/irrlicht_changes/CGUITTFont.h @@ -56,7 +56,7 @@ namespace gui private: static std::map faces; - static std::optional freetype_library; + static FT_Library freetype_library; static std::size_t n_faces; static FT_Library getFreeTypeLibrary();