From f63d65ae5ab9c85656a2f81ed4680f112029fe79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 29 Nov 2019 16:05:01 +0100 Subject: 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 --- source/blender/blenkernel/intern/workspace.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to '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) { -- cgit v1.2.3