Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

fix crash on switching scenes while selecting raster level frame

shun-iwasawa347846c325a6
diff --git a/toonz/sources/toonz/iocommand.cpp b/toonz/sources/toonz/iocommand.cpp
index e2856112f..4f00f2843 100644
--- a/toonz/sources/toonz/iocommand.cpp
+++ b/toonz/sources/toonz/iocommand.cpp
@@ -1316,6 +1316,10 @@ void IoCmd::newScene() {
if (!saveSceneIfNeeded(QApplication::tr("New Scene"))) return;
+ // temporary clear the current level to prevent UI to access deleted level
+ // while switching scenes
+ app->getCurrentLevel()->setLevel(nullptr);
+
IconGenerator::instance()->clearRequests();
IconGenerator::instance()->clearSceneIcons();
ImageManager::instance()->clear();
@@ -1909,6 +1913,11 @@ bool IoCmd::loadScene(const TFilePath &path, bool updateRecentFile,
}
QApplication::setOverrideCursor(Qt::WaitCursor);
+ TApp *app = TApp::instance();
+ // temporary clear the current level to prevent UI to access deleted level
+ // while switching scenes
+ app->getCurrentLevel()->setLevel(nullptr);
+
TUndoManager::manager()->reset();
IconGenerator::instance()->clearRequests();
IconGenerator::instance()->clearSceneIcons();
@@ -1963,7 +1972,6 @@ bool IoCmd::loadScene(const TFilePath &path, bool updateRecentFile,
project->setFolder("project", scenePath);
scene->setProject(project);
}
- TApp *app = TApp::instance();
app->getCurrentScene()->setScene(scene);
app->getCurrentScene()->notifyNameSceneChange();
app->getCurrentFrame()->setFrame(0);