Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2019-11-29 18:05:01 +0300
committerSybren A. Stüvel <sybren@blender.org>2019-11-29 18:05:01 +0300
commitf63d65ae5ab9c85656a2f81ed4680f112029fe79 (patch)
treef3c8b200124e20bc894350038be6914884c59af6
parent846e402b08d1ec2a11454fdcaac8392446109b87 (diff)
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
-rw-r--r--source/blender/blenkernel/intern/workspace.c7
1 files changed, 5 insertions, 2 deletions
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) {