Skip to content

Commit ee595ce

Browse files
committed
fix(core): add initialization checks and manage component states
1 parent fc76b53 commit ee595ce

4 files changed

Lines changed: 8 additions & 2 deletions

File tree

LDYOM2/src/core/scenes_manager.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,9 @@ void ScenesManager::resetCurrentScene() {
300300

301301
void ScenesManager::unloadCurrentScene() {
302302
m_currentScene = std::make_unique<Scene>(Scene{.info = SceneInfo{.name = _("scenes.default_scene_name")}});
303-
if (auto nodeEditor = WindowManager::instance().getWindowAs<NodeEditorWindow>("node_editor")) {
304-
(*nodeEditor)->clearGraph();
303+
if (WindowManager::instance().isInitialized()) {
304+
if (auto nodeEditor = WindowManager::instance().getWindowAs<NodeEditorWindow>("node_editor")) {
305+
(*nodeEditor)->clearGraph();
306+
}
305307
}
306308
}

LDYOM2/src/imgui_hook/imgui_hook.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,4 +508,5 @@ void ImguiHook::Remove() {
508508
ImGui_ImplWin32_Shutdown();
509509
ImGui::DestroyContext();
510510
MH_DisableHook(MH_ALL_HOOKS);
511+
m_bInitialized = false;
511512
}

LDYOM2/src/imgui_hook/render_hook.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ void ImGuiHook() {
3535
}
3636

3737
void ImGuiHookRemove() {
38+
if (!ImguiHook::m_bInitialized)
39+
return;
3840
ImguiHook::Remove();
3941
LDYOM_INFO("ImGui hook removed");
4042
}

LDYOM2/src/rendering/window_manager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class WindowManager {
5858

5959
void initialize();
6060
void shutdown() noexcept;
61+
bool isInitialized() const noexcept { return m_initialized; }
6162

6263
WindowManager(const WindowManager&) = delete;
6364
WindowManager& operator=(const WindowManager&) = delete;

0 commit comments

Comments
 (0)