OpenToonz - An open-source full-featured 2D animation creation software
C
fix initialize palette for a case when +palettes alias does not set to the current project
shun-iwasawa43e7a3d7ef69
diff --git a/toonz/sources/toonzlib/tproject.cpp b/toonz/sources/toonzlib/tproject.cppindex 08a0ace6b..baffe2a6a 100644--- a/toonz/sources/toonzlib/tproject.cpp+++ b/toonz/sources/toonzlib/tproject.cpp@@ -408,7 +408,7 @@ int TProject::getFolderIndex(string name) const {std::vector<std::string>::const_iterator it;it = std::find(m_folderNames.begin(), m_folderNames.end(), name);if (it == m_folderNames.end()) return -1;- return std::distance(it, m_folderNames.begin());+ return std::distance(m_folderNames.begin(), it);}//-------------------------------------------------------------------@@ -981,7 +981,7 @@ void TProjectManager::getFolderNames(std::vector<std::string> &names) {void TProjectManager::setCurrentProjectPath(const TFilePath &fp) {assert(TProject::isAProjectPath(fp));currentProjectPath = ::to_string(fp.getWideString());- currentProject = nullptr;// init this pointer in getCurrentProject()+ currentProject = nullptr; // init this pointer in getCurrentProject()notifyListeners();}@@ -1036,8 +1036,8 @@ std::shared_ptr<TProject> TProjectManager::getCurrentProject() {\note \b scenePath must be an absolute path.\nCreates a new TProject. The caller gets ownership.Sets *notFound to true if scenes.xml not found */-std::shared_ptr<TProject> TProjectManager::loadSceneProject(const TFilePath &scenePath,- bool* notFound) {+std::shared_ptr<TProject> TProjectManager::loadSceneProject(+ const TFilePath &scenePath, bool *notFound) {// cerca il file scenes.xml nella stessa directory della scena// oppure in una// directory superiore@@ -1076,11 +1076,10 @@ std::shared_ptr<TProject> TProjectManager::loadSceneProject(const TFilePath &sceprojectPath = path;} catch (...) {- throw TException("Error while reading scenes.xml");+ throw TException("Error while reading scenes.xml");}if (projectPath == TFilePath()) return 0;- }- else+ } elseprojectPath = getSandboxProjectPath();if (!TProject::isAProjectPath(projectPath)) {@@ -1131,7 +1130,7 @@ void TProjectManager::removeListener(Listener *listener) {\see TSceneProperties*/void TProjectManager::initializeScene(ToonzScene *scene) {- auto project = scene->getProject();+ auto project = scene->getProject();TSceneProperties *sprop = scene->getProperties();TFilePath currentProjectPath = getCurrentProjectPath();diff --git a/toonz/sources/toonzlib/txshsimplelevel.cpp b/toonz/sources/toonzlib/txshsimplelevel.cppindex 9d78a0f8b..bdc9fdbea 100644--- a/toonz/sources/toonzlib/txshsimplelevel.cpp+++ b/toonz/sources/toonzlib/txshsimplelevel.cpp@@ -1869,6 +1869,9 @@ void TXshSimpleLevel::initializePalette() {ToonzScene* scene = getScene();assert(scene);+ bool hasPalettesAlias =+ (scene->getProject()->getFolderIndex("palettes") >= 0);+TFilePath fullPath;TPalette* palette = nullptr;int type = getType();@@ -1876,7 +1879,7 @@ void TXshSimpleLevel::initializePalette() {case TZP_XSHLEVEL:fullPath =scene->decodeFilePath(TFilePath("+palettes\\Toonz_Raster_Palette.tpl"));- if (TSystem::doesExistFileOrLevel(fullPath)) {+ if (hasPalettesAlias && TSystem::doesExistFileOrLevel(fullPath)) {palette = new TPalette();TIStream is(fullPath);is >> palette;@@ -1889,14 +1892,14 @@ void TXshSimpleLevel::initializePalette() {palette = new TPalette();TIStream is(globalPath);is >> palette;- TSystem::copyFile(fullPath, globalPath);+ if (hasPalettesAlias) TSystem::copyFile(fullPath, globalPath);}}break;case PLI_XSHLEVEL:fullPath =scene->decodeFilePath(TFilePath("+palettes\\Toonz_Vector_Palette.tpl"));- if (TSystem::doesExistFileOrLevel(fullPath)) {+ if (hasPalettesAlias && TSystem::doesExistFileOrLevel(fullPath)) {palette = new TPalette();TIStream is(fullPath);is >> palette;@@ -1909,7 +1912,7 @@ void TXshSimpleLevel::initializePalette() {palette = new TPalette();TIStream is(globalPath);is >> palette;- TSystem::copyFile(fullPath, globalPath);+ if (hasPalettesAlias) TSystem::copyFile(fullPath, globalPath);}}break;