[Bf-blender-cvs] [d33ab08] asset-engine: Fix bad behavior when switching between asset engines with incompatible paths.

Bastien Montagne noreply at git.blender.org
Mon Dec 5 14:41:48 CET 2016


Commit: d33ab08132d478bc72d9e8817151b5afbf7799a4
Author: Bastien Montagne
Date:   Mon Dec 5 14:40:24 2016 +0100
Branches: asset-engine
https://developer.blender.org/rBd33ab08132d478bc72d9e8817151b5afbf7799a4

Fix bad behavior when switching between asset engines with incompatible paths.

A path valid for a given AE can be invalid with another, we need to
check current path when switching between AEs.

Also do proper check of valid path for Amber engines.

===================================================================

M	release/scripts/startup/bl_operators/amber.py
M	release/scripts/startup/bl_operators/amber_asyncio.py
M	source/blender/editors/space_file/filelist.c

===================================================================

diff --git a/release/scripts/startup/bl_operators/amber.py b/release/scripts/startup/bl_operators/amber.py
index 36c83ea..75eb6bf 100644
--- a/release/scripts/startup/bl_operators/amber.py
+++ b/release/scripts/startup/bl_operators/amber.py
@@ -602,11 +602,9 @@ class AssetEngineAmber(AssetEngine):
         return True
 
     def check_dir(self, entries, do_change):
-        # Stupid code just for test...
-        #~ if do_change:
-        #~     entries.root_path = entries.root_path + "../"
-        #~     print(entries.root_path)
-        return True
+        while do_change and not os.path.exists(entries.root_path):
+            entries.root_path = os.path.normpath(os.path.join(entries.root_path, ".."))
+        return os.path.exists(entries.root_path)
 
     def sort_filter(self, use_sort, use_filter, params, entries):
 #        print(use_sort, use_filter)
diff --git a/release/scripts/startup/bl_operators/amber_asyncio.py b/release/scripts/startup/bl_operators/amber_asyncio.py
index d4821db..9cc43d0 100644
--- a/release/scripts/startup/bl_operators/amber_asyncio.py
+++ b/release/scripts/startup/bl_operators/amber_asyncio.py
@@ -653,11 +653,9 @@ class AssetEngineAmberAIO(AssetEngine):
         return True
 
     def check_dir(self, entries, do_change):
-        # Stupid code just for test...
-        #~ if do_change:
-        #~     entries.root_path = entries.root_path + "../"
-        #~     print(entries.root_path)
-        return True
+        while do_change and not os.path.exists(entries.root_path):
+            entries.root_path = os.path.normpath(os.path.join(entries.root_path, ".."))
+        return os.path.exists(entries.root_path)
 
     def sort_filter(self, use_sort, use_filter, params, entries):
 #        print(use_sort, use_filter)
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index cecfd36..69a25c1 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -1508,6 +1508,9 @@ void filelist_assetengine_set(struct FileList *filelist, struct AssetEngineType
 	if (aet) {
 		filelist->ae = BKE_asset_engine_create(aet, NULL);
 	}
+
+	/* Current path of filelist may not be valid for new asset engine! */
+	filelist->checkdirf(filelist, filelist->filelist.root, true);
 	filelist->flags |= FL_FORCE_RESET;
 }




More information about the Bf-blender-cvs mailing list