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:
authorMitchell Stokes <mogurijin@gmail.com>2013-08-11 01:17:46 +0400
committerMitchell Stokes <mogurijin@gmail.com>2013-08-11 01:17:46 +0400
commit3627541894e2875b74d974abfe9ead60b68c4d05 (patch)
treeb4b24fc9e43b6873ea60ff1acc4793847a118d29 /source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
parent4c136881a5a17f411ea05588ee86479f94cc2429 (diff)
BGE: Fixing the memory leaks reported when the BlenderPlayer exits.
They were caused by not having a free_windowmanager_cb set and by not having registered SpaceTypes, which meant data allocated for thosse SpaceTypes could not be freed. These were solved by defining a free_windowmanager_cb for the player that just frees wmWindows, and by making sure we only allocate memory for registered SpaceTypes.
Diffstat (limited to 'source/gameengine/GamePlayer/ghost/GPG_ghost.cpp')
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_ghost.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
index 817a4d8efac..ccbcdd25639 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
+++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
@@ -118,6 +118,14 @@ static void mem_error_cb(const char *errorStr)
fflush(stderr);
}
+// library.c will only free window managers with a callback function.
+// We don't actually use a wmWindowManager, but loading a blendfile
+// loads wmWindows, so we need to free those.
+static void wm_free(bContext *C, wmWindowManager *wm)
+{
+ BLI_freelistN(&wm->windows);
+}
+
#ifdef WIN32
typedef enum {
SCREEN_SAVER_MODE_NONE = 0,
@@ -501,6 +509,8 @@ int main(int argc, char** argv)
sound_init_once();
+ set_free_windowmanager_cb(wm_free);
+
/* if running blenderplayer the last argument can't be parsed since it has to be the filename. */
isBlenderPlayer = !BLO_is_a_runtime(argv[0]);
if (isBlenderPlayer)