do not remove asset when auto save

This commit is contained in:
shun-iwasawa 2021-03-08 17:55:36 +09:00 committed by manongjohn
parent f41dfc8dba
commit b0698e3da6
3 changed files with 11 additions and 9 deletions

View file

@ -1402,6 +1402,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());
@ -1442,7 +1443,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(
@ -1556,7 +1557,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();
@ -1574,7 +1575,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);
}
}
@ -1719,10 +1720,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();

View file

@ -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();

View file

@ -745,9 +745,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();
}