diff --git a/toonz/sources/common/tapptools/tenv.cpp b/toonz/sources/common/tapptools/tenv.cpp index 784bbda..1880a56 100644 --- a/toonz/sources/common/tapptools/tenv.cpp +++ b/toonz/sources/common/tapptools/tenv.cpp @@ -41,6 +41,7 @@ const std::map systemPathMap{ class EnvGlobals { // singleton ToonzVersion m_version; + std::string m_applicationFileName; // May differ from application name std::string m_applicationVersion; std::string m_applicationFullName; std::string m_moduleName; @@ -76,7 +77,7 @@ public: QString settingsPath; #ifdef MACOSX - settingsPath = QString::fromStdString(getApplicationName()) + + settingsPath = QString::fromStdString(getApplicationFileName()) + QString(".app") + QString("/Contents/Resources/SystemVar.ini"); #else /* Generic Unix */ @@ -181,6 +182,10 @@ public: updateEnvFile(); } + void setApplicationFileName(std::string appFileName) { + m_applicationFileName = appFileName; + } + std::string getApplicationFileName() { return m_applicationFileName; } std::string getApplicationName() { return m_version.getAppName(); } std::string getApplicationVersion() { return m_applicationVersion; } std::string getApplicationVersionWithoutRevision() { @@ -231,12 +236,13 @@ public: // as a portable. Placing portablestuff inside OpenToonz.app will keep // everything together when it translocates. if (!m_isPortable) { - portableCheck = TFilePath(m_workingDirectory + "\\" + - getApplicationName() + ".app\\portablestuff\\"); + portableCheck = + TFilePath(m_workingDirectory + "\\" + getApplicationFileName() + + ".app\\portablestuff\\"); portableStatus = TFileStatus(portableCheck); m_isPortable = portableStatus.doesExist(); if (m_isPortable) - m_workingDirectory.append("\\" + getApplicationName() + ".app"); + m_workingDirectory.append("\\" + getApplicationFileName() + ".app"); } #endif } @@ -492,6 +498,15 @@ void Variable::assignValue(std::string value) { //=================================================================== +void TEnv::setApplicationFileName(std::string appFileName) { + TFilePath fp(appFileName); + EnvGlobals::instance()->setApplicationFileName(fp.getName()); +} + +std::string TEnv::getApplicationFileName() { + return EnvGlobals::instance()->getApplicationFileName(); +} + std::string TEnv::getApplicationName() { return EnvGlobals::instance()->getApplicationName(); } diff --git a/toonz/sources/include/tenv.h b/toonz/sources/include/tenv.h index dc793e1..a9130b5 100644 --- a/toonz/sources/include/tenv.h +++ b/toonz/sources/include/tenv.h @@ -93,6 +93,12 @@ public: DVAPI std::string getApplicationName(); DVAPI std::string getApplicationVersion(); +// This are for the case where the file name of application changes and doesn't +// match actual application name and we want to keep both. We will need that for +// some stuff +DVAPI void setApplicationFileName(std::string appFileName); +DVAPI std::string getApplicationFileName(); + DVAPI bool getIsPortable(); // es.: TEnv::setModuleFullName("Toonz 5.0.1 Harlequin"); diff --git a/toonz/sources/toonz/main.cpp b/toonz/sources/toonz/main.cpp index 8fb85fe..88d5117 100644 --- a/toonz/sources/toonz/main.cpp +++ b/toonz/sources/toonz/main.cpp @@ -237,6 +237,8 @@ project->setUseScenePath(TProject::Extras, false); //----------------------------------------------------------------------------- int main(int argc, char *argv[]) { + TEnv::setApplicationFileName(argv[0]); + #ifdef Q_OS_WIN // Enable standard input/output on Windows Platform for debug BOOL consoleAttached = ::AttachConsole(ATTACH_PARENT_PROCESS);