Skip to content

Commit

Permalink
[emapp] fix a crash bug after effect compilation failure (#96)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hkrn authored Jan 5, 2022
1 parent 27efc3a commit 4292220
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/change_log.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

* エフェクトで利用する画像読み込み起因で不正な描画が発生することがある
* オフスクリーンを使ったエフェクトでリロードあるいはファイル書き換えで落ちる
* ポストエフェクトのコンパイルに失敗すると落ちることがある

34.2.0 (2021/11/3)
******************************************
Expand Down
3 changes: 3 additions & 0 deletions emapp/src/DefaultFileManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,7 @@ DefaultFileManager::loadModel(
}
}
if (!succeeded) {
project->removeModel(model);
project->destroyModel(model);
}
}
Expand All @@ -971,6 +972,7 @@ DefaultFileManager::loadModel(
}
}
if (!succeeded) {
project->removeAccessory(accessory);
project->destroyAccessory(accessory);
}
progress.complete();
Expand Down Expand Up @@ -1227,6 +1229,7 @@ DefaultFileManager::loadModelFromArchive(
canDestroyFileReader = false;
}
else {
project->removeModel(model);
project->destroyModel(model);
}
}
Expand Down
3 changes: 3 additions & 0 deletions emapp/src/ModalDialogFactory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -218,6 +219,7 @@ LoadingModelConfirmDialog::onAccepted(Project *project)
m_model->setVisible(true);
}
else {
project->removeModel(m_model);
project->destroyModel(m_model);
}
m_model = nullptr;
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions emapp/src/Project.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1845,6 +1845,7 @@ Project::newModel(Error &error)
scope.commit(error);
}
else {
removeModel(model);
destroyModel(model);
scope.rollback(error);
}
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -4273,6 +4276,7 @@ Project::destroyEffect(Effect *effect)
}
}
}
cancelRenderOffscreenRenderTarget(effect);
destroyDetachedEffect(effect);
}
}
Expand Down
2 changes: 2 additions & 0 deletions emapp/src/internal/project/Archive.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 4292220

Please sign in to comment.