fix crash on switching scenes while selecting raster level frame

This commit is contained in:
shun-iwasawa 2022-02-24 14:08:45 +09:00 committed by manongjohn
parent ed876b10cc
commit 0f2f032bbb

View file

@ -1319,6 +1319,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();
@ -1921,6 +1925,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();
@ -1976,7 +1985,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);