Skip to content

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

C

fix import scene

shun_iwasawa3f8574e52235
diff --git a/toonz/sources/toonzlib/sceneresources.cpp b/toonz/sources/toonzlib/sceneresources.cpp
index 0a9b611e3..513c5f5b6 100644
--- a/toonz/sources/toonzlib/sceneresources.cpp
+++ b/toonz/sources/toonzlib/sceneresources.cpp
@@ -540,9 +540,13 @@ ResourceImporter::ResourceImporter(ToonzScene *scene, TProject *dstProject,
, m_dstScene(new ToonzScene())
, m_importStrategy(importStrategy) {
m_dstScene->setProject(dstProject);
- TFilePath newFp =
- dstProject->getScenesPath() +
- (scene->getScenePath() - scene->getProject()->getScenesPath());
+ // scene file may not be in the "+scenes" path for the sandbox project.
+ // in such case, try to save as "+scenes/filename.tnz" on import.
+ TFilePath relativeScenePath =
+ scene->getScenePath() - scene->getProject()->getScenesPath();
+ if (relativeScenePath.isAbsolute())
+ relativeScenePath = scene->getScenePath().withoutParentDir();
+ TFilePath newFp = dstProject->getScenesPath() + relativeScenePath;
makeUnique(newFp);
m_dstScene->setScenePath(newFp);
}