From 4292220d07a4bbac4db78ad39eb9d8c708e15f77 Mon Sep 17 00:00:00 2001 From: "hkrn (a.k.a shimacpyon)" <129939+hkrn@users.noreply.github.com> Date: Thu, 6 Jan 2022 01:34:12 +0900 Subject: [PATCH] [emapp] fix a crash bug after effect compilation failure (#96) The crash bug will be fired when loading the accessory/model with post-effect and fail of compilation due to insufficient cleanup. The commit ensures calling removeAccessory or removeModel method as possible and cancelRenderOffscreenRenderTarget for the effect that contains `OFFSCREENRENDERTARGET` semantic. --- docs/change_log.rst | 1 + emapp/src/DefaultFileManager.cc | 3 +++ emapp/src/ModalDialogFactory.cc | 3 +++ emapp/src/Project.cc | 4 ++++ emapp/src/internal/project/Archive.cc | 2 ++ 5 files changed, 13 insertions(+) diff --git a/docs/change_log.rst b/docs/change_log.rst index 6ddff620..ba998ea7 100644 --- a/docs/change_log.rst +++ b/docs/change_log.rst @@ -13,6 +13,7 @@ * エフェクトで利用する画像読み込み起因で不正な描画が発生することがある * オフスクリーンを使ったエフェクトでリロードあるいはファイル書き換えで落ちる +* ポストエフェクトのコンパイルに失敗すると落ちることがある 34.2.0 (2021/11/3) ****************************************** diff --git a/emapp/src/DefaultFileManager.cc b/emapp/src/DefaultFileManager.cc index e9207869..93b329d0 100644 --- a/emapp/src/DefaultFileManager.cc +++ b/emapp/src/DefaultFileManager.cc @@ -955,6 +955,7 @@ DefaultFileManager::loadModel( } } if (!succeeded) { + project->removeModel(model); project->destroyModel(model); } } @@ -971,6 +972,7 @@ DefaultFileManager::loadModel( } } if (!succeeded) { + project->removeAccessory(accessory); project->destroyAccessory(accessory); } progress.complete(); @@ -1227,6 +1229,7 @@ DefaultFileManager::loadModelFromArchive( canDestroyFileReader = false; } else { + project->removeModel(model); project->destroyModel(model); } } diff --git a/emapp/src/ModalDialogFactory.cc b/emapp/src/ModalDialogFactory.cc index ccbf0278..8df37750 100644 --- a/emapp/src/ModalDialogFactory.cc +++ b/emapp/src/ModalDialogFactory.cc @@ -171,6 +171,7 @@ LoadingModelConfirmDialog::~LoadingModelConfirmDialog() NANOEM_DECL_NOEXCEPT { if (m_model) { Project *project = m_model->project(); + project->removeModel(m_model); project->destroyModel(m_model); m_model = nullptr; } @@ -218,6 +219,7 @@ LoadingModelConfirmDialog::onAccepted(Project *project) m_model->setVisible(true); } else { + project->removeModel(m_model); project->destroyModel(m_model); } m_model = nullptr; @@ -333,6 +335,7 @@ LoadingArchivedModelConfirmDialog::~LoadingArchivedModelConfirmDialog() NANOEM_D { if (m_model) { Project *project = m_model->project(); + project->removeModel(m_model); project->destroyModel(m_model); m_model = nullptr; if (m_callback.m_callback) { diff --git a/emapp/src/Project.cc b/emapp/src/Project.cc index d4e5c74f..b4420694 100644 --- a/emapp/src/Project.cc +++ b/emapp/src/Project.cc @@ -1845,6 +1845,7 @@ Project::newModel(Error &error) scope.commit(error); } else { + removeModel(model); destroyModel(model); scope.rollback(error); } @@ -1934,11 +1935,13 @@ Project::convertAccessoryToModel(Accessory *accessory, Error &error) progress.complete(); } else { + removeModel(model); destroyModel(model); scope.rollback(error); } } else { + removeModel(model); destroyModel(model); } } @@ -4273,6 +4276,7 @@ Project::destroyEffect(Effect *effect) } } } + cancelRenderOffscreenRenderTarget(effect); destroyDetachedEffect(effect); } } diff --git a/emapp/src/internal/project/Archive.cc b/emapp/src/internal/project/Archive.cc index 58c9d62a..a572dae0 100644 --- a/emapp/src/internal/project/Archive.cc +++ b/emapp/src/internal/project/Archive.cc @@ -274,6 +274,7 @@ Archive::loadAccessory(const String &entryPath, Error &error) m_progress->increment(); } else { + m_project->removeAccessory(accessory); m_project->destroyAccessory(accessory); continuable = false; } @@ -321,6 +322,7 @@ Archive::loadModel(const String &entryPath, Error &error) m_progress->increment(); } else { + m_project->removeModel(model); m_project->destroyModel(model); } return continuable;