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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2008-09-16 23:25:35 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2008-09-16 23:25:35 +0400
commitc6d0be2a9943818b98db3831e5d56969bd95c5fa (patch)
treeb9a870f848e0b5d7141bb6a47dbad77d746ce0c6 /source/gameengine/GamePlayer/ghost/GPG_Application.cpp
parent75685a9ca842022519b451bea14b442f69487d9a (diff)
Fix (harmless) error print about GameLogic.globalDict being lost. Also
fixed some memory leaks in this code and simplified it.
Diffstat (limited to 'source/gameengine/GamePlayer/ghost/GPG_Application.cpp')
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_Application.cpp29
1 files changed, 19 insertions, 10 deletions
diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
index 580c80ee0a5..752b776beff 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
+++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
@@ -115,6 +115,7 @@ GPG_Application::GPG_Application(GHOST_ISystem* system)
m_cursor(GHOST_kStandardCursorFirstCursor),
m_engineInitialized(0),
m_engineRunning(0),
+ m_isEmbedded(false),
m_ketsjiengine(0),
m_kxsystem(0),
m_keyboard(0),
@@ -128,8 +129,7 @@ GPG_Application::GPG_Application(GHOST_ISystem* system)
m_blendermat(0),
m_blenderglslmat(0),
m_pyGlobalDictString(0),
- m_pyGlobalDictString_Length(0),
- m_isEmbedded(false)
+ m_pyGlobalDictString_Length(0)
{
fSystem = system;
}
@@ -138,6 +138,12 @@ GPG_Application::GPG_Application(GHOST_ISystem* system)
GPG_Application::~GPG_Application(void)
{
+ if(m_pyGlobalDictString) {
+ delete m_pyGlobalDictString;
+ m_pyGlobalDictString = 0;
+ m_pyGlobalDictString_Length = 0;
+ }
+
exitEngine();
fSystem->disposeWindow(m_mainWindow);
}
@@ -680,7 +686,8 @@ bool GPG_Application::startEngine(void)
initPythonConstraintBinding();
initMathutils();
- /* Restore the dict */
+ // Set the GameLogic.globalDict from marshal'd data, so we can
+ // load new blend files and keep data in GameLogic.globalDict
loadGamePythonConfig(m_pyGlobalDictString, m_pyGlobalDictString_Length);
m_sceneconverter->ConvertScene(
@@ -718,13 +725,15 @@ bool GPG_Application::startEngine(void)
void GPG_Application::stopEngine()
{
- // get the python dict and convert to a string for future use
- char *marshal_buffer;
- m_pyGlobalDictString_Length = saveGamePythonConfig(&marshal_buffer);
- if (m_pyGlobalDictString_Length) {
- m_pyGlobalDictString = static_cast<char *> (malloc(m_pyGlobalDictString_Length));
- memcpy(m_pyGlobalDictString, marshal_buffer, m_pyGlobalDictString_Length);
- }
+ // GameLogic.globalDict gets converted into a buffer, and sorted in
+ // m_pyGlobalDictString so we can restore after python has stopped
+ // and started between .blend file loads.
+ if(m_pyGlobalDictString) {
+ delete m_pyGlobalDictString;
+ m_pyGlobalDictString = 0;
+ }
+
+ m_pyGlobalDictString_Length = saveGamePythonConfig(&m_pyGlobalDictString);
// when exiting the mainloop
exitGamePythonScripting();