Use 'empty' option for clearing factory settings
authorCampbell Barton <ideasman42@gmail.com>
Wed, 29 Mar 2017 08:18:09 +0000 (19:18 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 29 Mar 2017 09:11:54 +0000 (20:11 +1100)
tests/python/batch_import.py
tests/python/bl_run_operators.py

index 8fc679a7c154deccd2ef61797f021da15dc90f09..bbe3a70327f61f7ab55ff4eff5e603bc2635ed8d 100644 (file)
@@ -48,29 +48,17 @@ import os
 import sys
 
 
-def clear_scene():
-    import bpy
-    unique_obs = set()
-    for scene in bpy.data.scenes:
-        for obj in scene.objects[:]:
-            scene.objects.unlink(obj)
-            unique_obs.add(obj)
-
-    # remove obdata, for now only worry about the startup scene
-    for bpy_data_iter in (bpy.data.objects, bpy.data.meshes, bpy.data.lamps, bpy.data.cameras):
-        for id_data in bpy_data_iter:
-            bpy_data_iter.remove(id_data)
-
-
-def batch_import(operator="",
-                 path="",
-                 save_path="",
-                 match="",
-                 start=0,
-                 end=sys.maxsize,
-                 ):
+def batch_import(
+    operator="",
+    path="",
+    save_path="",
+    match="",
+    start=0,
+    end=sys.maxsize,
+):
     import addon_utils
     _reset_all = addon_utils.reset_all  # XXX, hack
+    _disable_all = addon_utils.disable_all  # XXX, hack
 
     import fnmatch
 
@@ -116,11 +104,12 @@ def batch_import(operator="",
 
         # hack so loading the new file doesn't undo our loaded addons
         addon_utils.reset_all = lambda: None  # XXX, hack
+        addon_utils.disable_all = lambda: None  # XXX, hack
 
-        bpy.ops.wm.read_factory_settings()
+        bpy.ops.wm.read_factory_settings(use_empty=True)
 
         addon_utils.reset_all = _reset_all  # XXX, hack
-        clear_scene()
+        addon_utils.disable_all = _disable_all  # XXX, hack
 
         result = op(filepath=f)
 
index 7e92b424faad9d32b60c24843fc23850a8724b7c..7d5f4127378eadaa04e730b8e81480da33cdddc0 100644 (file)
@@ -65,6 +65,7 @@ op_blacklist = (
     "wm.blenderplayer_start",
     "wm.recover_auto_save",
     "wm.quit_blender",
+    "wm.window_close",
     "wm.url_open",
     "wm.doc_view",
     "wm.doc_edit",
@@ -308,16 +309,7 @@ def run_ops(operators, setup_func=None, reset=True):
 
 # contexts
 def ctx_clear_scene():  # copied from batch_import.py
-    unique_obs = set()
-    for scene in bpy.data.scenes:
-        for obj in scene.objects[:]:
-            scene.objects.unlink(obj)
-            unique_obs.add(obj)
-
-    # remove obdata, for now only worry about the startup scene
-    for bpy_data_iter in (bpy.data.objects, bpy.data.meshes, bpy.data.lamps, bpy.data.cameras):
-        for id_data in bpy_data_iter:
-            bpy_data_iter.remove(id_data)
+    bpy.ops.wm.read_factory_settings(use_empty=True)
 
 
 def ctx_editmode_mesh():