[Bf-blender-cvs] [44e813db3c5] sybren-usd: Deinitialisation of Blender
Sybren A. Stüvel
noreply at git.blender.org
Thu Nov 21 10:36:14 CET 2019
Commit: 44e813db3c5230fd99432ff292f2ff48a7f153c7
Author: Sybren A. Stüvel
Date: Fri Nov 15 14:38:33 2019 +0100
Branches: sybren-usd
https://developer.blender.org/rB44e813db3c5230fd99432ff292f2ff48a7f153c7
Deinitialisation of Blender
===================================================================
M tests/gtests/blenloader/blendfile_loading_base_test.cc
M tests/gtests/blenloader/blendfile_loading_base_test.h
M tests/gtests/testing/CMakeLists.txt
===================================================================
diff --git a/tests/gtests/blenloader/blendfile_loading_base_test.cc b/tests/gtests/blenloader/blendfile_loading_base_test.cc
index b6a0ec82ee6..d96b0dd07f4 100644
--- a/tests/gtests/blenloader/blendfile_loading_base_test.cc
+++ b/tests/gtests/blenloader/blendfile_loading_base_test.cc
@@ -18,6 +18,7 @@
#include "blendfile_loading_base_test.h"
extern "C" {
+#include "BKE_appdir.h"
#include "BKE_blender.h"
#include "BKE_context.h"
#include "BKE_global.h"
@@ -75,9 +76,43 @@ void BlendfileLoadingBaseTest::SetUpTestCase()
/* Allocate a dummy window manager. The real window manager will try and load Python scripts from
* the release directory, which it won't be able ot find. */
+ ASSERT_EQ(G.main->wm.first, nullptr);
G.main->wm.first = MEM_callocN(sizeof(wmWindowManager), __func__);
}
+void BlendfileLoadingBaseTest::TearDownTestCase()
+{
+ if (G.main->wm.first != nullptr) {
+ MEM_freeN(G.main->wm.first);
+ G.main->wm.first = nullptr;
+ }
+
+ /* Copied from WM_exit_ex() in wm_init_exit.c, and cherry-picked those lines that match the
+ * allocation/initialisation done in SetUpTestCase(). */
+ BKE_blender_free();
+ RNA_exit();
+
+ DEG_free_node_types();
+ DNA_sdna_current_free();
+ BLI_threadapi_exit();
+
+ BKE_blender_atexit();
+
+ /* TODO(Sybren): this reports 3 leaked blocks from WM, which have been allocated by loading a
+ * blend file. */
+ if (MEM_get_memory_blocks_in_use() != 0) {
+ size_t mem_in_use = MEM_get_memory_in_use() + MEM_get_memory_in_use();
+ printf("Error: Not freed memory blocks: %u, total unfreed memory %f MB\n",
+ MEM_get_memory_blocks_in_use(),
+ (double)mem_in_use / 1024 / 1024);
+ MEM_printmemlist();
+ }
+
+ BKE_tempdir_session_purge();
+
+ testing::Test::TearDownTestCase();
+}
+
void BlendfileLoadingBaseTest::TearDown()
{
depsgraph_free();
diff --git a/tests/gtests/blenloader/blendfile_loading_base_test.h b/tests/gtests/blenloader/blendfile_loading_base_test.h
index bcaf82db06b..466bbcd2392 100644
--- a/tests/gtests/blenloader/blendfile_loading_base_test.h
+++ b/tests/gtests/blenloader/blendfile_loading_base_test.h
@@ -19,7 +19,7 @@
#define __BLENDFILE_LOADING_BASE_TEST_H__
#include "testing/testing.h"
-#include <DEG_depsgraph.h>
+#include "DEG_depsgraph.h"
struct BlendFileData;
struct Depsgraph;
@@ -35,6 +35,7 @@ class BlendfileLoadingBaseTest : public testing::Test {
/* Sets up Blender just enough to not crash on loading
* a blendfile and constructing a depsgraph. */
static void SetUpTestCase();
+ static void TearDownTestCase();
protected:
/* Frees the depsgraph & blendfile. */
diff --git a/tests/gtests/testing/CMakeLists.txt b/tests/gtests/testing/CMakeLists.txt
index 6bbbfdd5d89..e08ee486933 100644
--- a/tests/gtests/testing/CMakeLists.txt
+++ b/tests/gtests/testing/CMakeLists.txt
@@ -14,7 +14,7 @@
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
-# The Original Code is Copyright (C) 2014, by Blender Foundation
+# The Original Code is Copyright (C) 2014, Blender Foundation
# All rights reserved.
# ***** END GPL LICENSE BLOCK *****
More information about the Bf-blender-cvs
mailing list