From b2cd4e2eca968370f48e60cc722732e3eaa0ebb3 Mon Sep 17 00:00:00 2001 From: Frederic Devernay Date: Sat, 10 Jul 2021 19:26:04 -0700 Subject: [PATCH] Python: expand variables in app.saveProject and app.saveProjectAs --- CHANGELOG.md | 2 ++ Engine/PyAppInstance.cpp | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c5915243e2..296f5dd719 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ - Fix Retina/High-DPI display issues on macOS, Windows and Linux/X11. #635 - Fix multi-dimensional parameter linking (bug introduced in 2.4.0 #594). #631 - Fix bug where any argument containing an integer between commas would be interpreted as a frame range. #644 +- Python: `app.saveProject` and `app.saveProjectAs` now do project variable substitution, as in `app.saveProjectAs("[Variable]/output.ntp")`. ### Plugins @@ -30,6 +31,7 @@ - Merge: Fix behavior on most operators when A is not connected or A's RoD and B's RoD are disjoint. #647 - Reformat: fix bugs when "turn" is checked with Resize Type = None or Type = Scale. + ## Version 2.4.0 ### Changes diff --git a/Engine/PyAppInstance.cpp b/Engine/PyAppInstance.cpp index 96773c9500..6fec7cb380 100644 --- a/Engine/PyAppInstance.cpp +++ b/Engine/PyAppInstance.cpp @@ -416,13 +416,23 @@ App::saveTempProject(const QString& filename) bool App::saveProject(const QString& filename) { - return getInternalApp()->save( filename.toStdString() ); + std::string outFile = filename.toStdString(); + std::map env; + getInternalApp()->getProject()->getEnvironmentVariables(env); + Project::expandVariable(env, outFile); + + return getInternalApp()->save(outFile); } bool App::saveProjectAs(const QString& filename) { - return getInternalApp()->saveAs( filename.toStdString() ); + std::string outFile = filename.toStdString(); + std::map env; + getInternalApp()->getProject()->getEnvironmentVariables(env); + Project::expandVariable(env, outFile); + + return getInternalApp()->saveAs(outFile); } App*