fixing crash when initializing the mlx multiple times

This commit is contained in:
Kbz-8
2024-10-19 10:50:50 +02:00
parent c45a76a5bf
commit 04f9cb1d95
5 changed files with 16 additions and 5 deletions

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */ /* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 22:10:52 by maldavid #+# #+# */ /* Created: 2022/10/04 22:10:52 by maldavid #+# #+# */
/* Updated: 2024/04/24 13:52:18 by maldavid ### ########.fr */ /* Updated: 2024/10/19 10:49:21 by maldavid ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -118,7 +118,9 @@ namespace mlx::core
Application::~Application() Application::~Application()
{ {
TextLibrary::get().clearLibrary(); TextLibrary::get().clearLibrary();
TextLibrary::get().reset();
FontLibrary::get().clearLibrary(); FontLibrary::get().clearLibrary();
FontLibrary::get().reset();
if(__drop_sdl_responsability) if(__drop_sdl_responsability)
return; return;
SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_EVENTS); SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_EVENTS);

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */ /* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/15 19:57:49 by maldavid #+# #+# */ /* Created: 2023/12/15 19:57:49 by maldavid #+# #+# */
/* Updated: 2024/01/11 03:13:21 by maldavid ### ########.fr */ /* Updated: 2024/10/19 10:47:04 by maldavid ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -59,5 +59,6 @@ namespace mlx
buf.destroy(); buf.destroy();
}); });
_pool.destroy(); _pool.destroy();
_buffers.clear();
} }
} }

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */ /* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/17 23:33:34 by maldavid #+# #+# */ /* Created: 2022/12/17 23:33:34 by maldavid #+# #+# */
/* Updated: 2024/04/23 20:32:54 by kiroussa ### ########.fr */ /* Updated: 2024/10/19 10:50:13 by maldavid ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -116,6 +116,8 @@ namespace mlx
void Render_Core::init() void Render_Core::init()
{ {
if(_is_init)
return;
if(volkInitialize() != VK_SUCCESS) if(volkInitialize() != VK_SUCCESS)
core::error::report(e_kind::fatal_error, "Vulkan loader : cannot load %s, are you sure Vulkan is installed on your system ?", VULKAN_LIB_NAME); core::error::report(e_kind::fatal_error, "Vulkan loader : cannot load %s, are you sure Vulkan is installed on your system ?", VULKAN_LIB_NAME);
@@ -144,6 +146,8 @@ namespace mlx
_layers.destroy(); _layers.destroy();
_instance.destroy(); _instance.destroy();
volkFinalize();
_is_init = false; _is_init = false;
} }
} }

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */ /* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/18 09:26:03 by maldavid #+# #+# */ /* Created: 2024/01/18 09:26:03 by maldavid #+# #+# */
/* Updated: 2024/01/18 09:33:30 by maldavid ### ########.fr */ /* Updated: 2024/10/19 10:47:32 by maldavid ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -38,6 +38,8 @@ namespace mlx
void clearLibrary(); void clearLibrary();
inline void reset() { _cache.clear(); _invalid_ids.clear(); _current_id = 1; }
private: private:
FontLibrary() = default; FontLibrary() = default;
~FontLibrary() = default; ~FontLibrary() = default;

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */ /* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/10 11:52:30 by maldavid #+# #+# */ /* Created: 2023/04/10 11:52:30 by maldavid #+# #+# */
/* Updated: 2024/03/25 16:04:47 by maldavid ### ########.fr */ /* Updated: 2024/10/19 10:49:02 by maldavid ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -39,6 +39,8 @@ namespace mlx
void clearLibrary(); void clearLibrary();
inline void reset() { _cache.clear(); _current_id = 1; }
private: private:
TextLibrary() = default; TextLibrary() = default;
~TextLibrary() = default; ~TextLibrary() = default;