From 77240013a4b08a9afa13132dd84d0080a32c7998 Mon Sep 17 00:00:00 2001 From: Kbz-8 Date: Sun, 27 Oct 2024 21:18:22 +0100 Subject: [PATCH] fixing segfault at exit --- runtime/Includes/Core/Graphics.inl | 4 ++-- runtime/Includes/Graphics/Font.h | 1 + runtime/Includes/Graphics/Font.inl | 5 +++++ runtime/Sources/Core/Application.cpp | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/runtime/Includes/Core/Graphics.inl b/runtime/Includes/Core/Graphics.inl index 8806200..c0df6e5 100644 --- a/runtime/Includes/Core/Graphics.inl +++ b/runtime/Includes/Core/Graphics.inl @@ -43,10 +43,10 @@ namespace mlx Text& new_text = p_scene->CreateText(str); new_text.SetPosition(Vec2f{ static_cast(x), static_cast(y) }); new_text.SetColor(std::move(vec_color)); - if(m_pixelput_called) + // if(m_pixelput_called) { m_draw_layer++; - m_pixelput_called = false; + // m_pixelput_called = false; } } else if(!p_scene->IsTextAtGivenDrawLayer(str, m_draw_layer)) diff --git a/runtime/Includes/Graphics/Font.h b/runtime/Includes/Graphics/Font.h index dec3805..a082ee1 100644 --- a/runtime/Includes/Graphics/Font.h +++ b/runtime/Includes/Graphics/Font.h @@ -39,6 +39,7 @@ namespace mlx inline void RegisterFont(std::shared_ptr font); inline void UnregisterFont(std::shared_ptr font); inline std::shared_ptr GetFont(const std::filesystem::path& name, float scale); + inline void Reset(); ~FontRegistry() = default; diff --git a/runtime/Includes/Graphics/Font.inl b/runtime/Includes/Graphics/Font.inl index 7e49e0a..f2a684e 100644 --- a/runtime/Includes/Graphics/Font.inl +++ b/runtime/Includes/Graphics/Font.inl @@ -21,4 +21,9 @@ namespace mlx }); return (it != m_fonts_registry.end() ? *it : nullptr); } + + void FontRegistry::Reset() + { + m_fonts_registry.clear(); + } } diff --git a/runtime/Sources/Core/Application.cpp b/runtime/Sources/Core/Application.cpp index fd2cd36..ce32c96 100644 --- a/runtime/Sources/Core/Application.cpp +++ b/runtime/Sources/Core/Application.cpp @@ -103,6 +103,7 @@ namespace mlx window.reset(); } + m_font_registry.Reset(); p_render_core.reset(); p_sdl_manager.reset(); #ifdef PROFILER