Skip to content

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

C

do not remove asset when auto save

shun-iwasawaefd29007478b
diff --git a/toonz/sources/toonz/iocommand.cpp b/toonz/sources/toonz/iocommand.cpp
index d20d94dd5..25e659309 100644
--- a/toonz/sources/toonz/iocommand.cpp
+++ b/toonz/sources/toonz/iocommand.cpp
@@ -1392,6 +1392,7 @@ void IoCmd::newScene() {
bool IoCmd::saveScene(const TFilePath &path, int flags) {
bool overwrite = (flags & SILENTLY_OVERWRITE) != 0;
bool saveSubxsheet = (flags & SAVE_SUBXSHEET) != 0;
+ bool isAutosave = (flags & AUTO_SAVE) != 0;
TApp *app = TApp::instance();
assert(!path.isEmpty());
@@ -1432,7 +1433,7 @@ bool IoCmd::saveScene(const TFilePath &path, int flags) {
if (saveSubxsheet) xsheet = TApp::instance()->getCurrentXsheet()->getXsheet();
// Automatically remove unused levels
- if (!saveSubxsheet &&
+ if (!saveSubxsheet && !isAutosave &&
Preferences::instance()->isAutoRemoveUnusedLevelsEnabled()) {
if (LevelCmd::removeUnusedLevelsFromCast(false))
DVGui::info(
@@ -1546,7 +1547,7 @@ bool IoCmd::saveScene(const TFilePath &path, int flags) {
// IoCmd::saveScene()
//---------------------------------------------------------------------------
-bool IoCmd::saveScene() {
+bool IoCmd::saveScene(int flags) {
TSelection *oldSelection =
TApp::instance()->getCurrentSelection()->getSelection();
ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene();
@@ -1564,7 +1565,7 @@ bool IoCmd::saveScene() {
} else {
TFilePath fp = scene->getScenePath();
// salva la scena con il nome fp. se fp esiste gia' lo sovrascrive
- return saveScene(fp, SILENTLY_OVERWRITE);
+ return saveScene(fp, SILENTLY_OVERWRITE | flags);
}
}
@@ -1709,10 +1710,10 @@ bool IoCmd::saveLevel(TXshSimpleLevel *sl) {
// IoCmd::saveAll()
//---------------------------------------------------------------------------
-bool IoCmd::saveAll() {
+bool IoCmd::saveAll(int flags) {
// try to save as much as possible
// if anything is wrong, return false
- bool result = saveScene();
+ bool result = saveScene(flags);
TApp *app = TApp::instance();
ToonzScene *scene = app->getCurrentScene()->getScene();
diff --git a/toonz/sources/toonz/iocommand.h b/toonz/sources/toonz/iocommand.h
index 634878206..b72a85451 100644
--- a/toonz/sources/toonz/iocommand.h
+++ b/toonz/sources/toonz/iocommand.h
@@ -186,6 +186,7 @@ bool loadSubScene(const TFilePath &scenePath);
enum SaveSceneFlags {
SILENTLY_OVERWRITE = 0x1,
SAVE_SUBXSHEET = 0x2,
+ AUTO_SAVE = 0x4
};
// ritorna true sse la scena e' stata salvata
@@ -196,7 +197,7 @@ enum SaveSceneFlags {
// 0 salva comunque
// tutta la scena, altrimenti solo il sottoxsheet
bool saveScene(const TFilePath &fp, int flags);
-bool saveScene();
+bool saveScene(int flags = 0);
bool saveLevel(const TFilePath &fp);
bool saveLevel();
@@ -204,7 +205,7 @@ bool saveLevel();
bool saveLevel(const TFilePath &fp, TXshSimpleLevel *sl, bool overwrite);
bool saveLevel(TXshSimpleLevel *sl);
-bool saveAll();
+bool saveAll(int flags = 0);
void saveNonSceneFiles();
diff --git a/toonz/sources/toonz/tapp.cpp b/toonz/sources/toonz/tapp.cpp
index 15654775b..0f6030ccb 100644
--- a/toonz/sources/toonz/tapp.cpp
+++ b/toonz/sources/toonz/tapp.cpp
@@ -706,9 +706,9 @@ void TApp::autosave() {
pb.show();
Preferences *pref = Preferences::instance();
if (pref->isAutosaveSceneEnabled() && pref->isAutosaveOtherFilesEnabled()) {
- IoCmd::saveAll();
+ IoCmd::saveAll(IoCmd::AUTO_SAVE);
} else if (pref->isAutosaveSceneEnabled()) {
- IoCmd::saveScene();
+ IoCmd::saveScene(IoCmd::AUTO_SAVE);
} else if (pref->isAutosaveOtherFilesEnabled()) {
IoCmd::saveNonSceneFiles();
}