[Bf-blender-cvs] [f63d65ae5ab] master: Tests: prevent failing assertion when running blendfile-loading test

Sybren A. Stüvel noreply at git.blender.org
Fri Nov 29 16:05:20 CET 2019


Commit: f63d65ae5ab9c85656a2f81ed4680f112029fe79
Author: Sybren A. Stüvel
Date:   Fri Nov 29 16:05:01 2019 +0100
Branches: master
https://developer.blender.org/rBf63d65ae5ab9c85656a2f81ed4680f112029fe79

Tests: prevent failing assertion when running blendfile-loading test

Loading a blendfile allocates one or more windows that need to be freed.
Freeing those windows also calls `BKE_workspace_instance_hook_free()` to
free workspaces. However, in the `BlendfileLoadingBaseTest` test there are
no workspaces allocated. This caused an assertion failure, which was worked
around by not asserting when Blender is running in background mode.

Reviewed by @Severin via pair programming

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

M	source/blender/blenkernel/intern/workspace.c

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

diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c
index dd2b182474e..3e449fa6b25 100644
--- a/source/blender/blenkernel/intern/workspace.c
+++ b/source/blender/blenkernel/intern/workspace.c
@@ -26,6 +26,7 @@
 #include "BLI_string_utils.h"
 #include "BLI_listbase.h"
 
+#include "BKE_global.h"
 #include "BKE_idprop.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
@@ -202,8 +203,10 @@ WorkSpaceInstanceHook *BKE_workspace_instance_hook_create(const Main *bmain)
 }
 void BKE_workspace_instance_hook_free(const Main *bmain, WorkSpaceInstanceHook *hook)
 {
-  /* workspaces should never be freed before wm (during which we call this function) */
-  BLI_assert(!BLI_listbase_is_empty(&bmain->workspaces));
+  /* workspaces should never be freed before wm (during which we call this function).
+   * However, when running in background mode, loading a blend file may allocate windows (that need
+   * to be freed) without creating workspaces. This happens in BlendfileLoadingBaseTest. */
+  BLI_assert(!BLI_listbase_is_empty(&bmain->workspaces) || G.background);
 
   /* Free relations for this hook */
   for (WorkSpace *workspace = bmain->workspaces.first; workspace; workspace = workspace->id.next) {



More information about the Bf-blender-cvs mailing list