fix shutdown error

This commit is contained in:
David Rose 2009-10-02 22:10:51 +00:00
parent d6647e3a85
commit a257cbbfba

View File

@ -45,6 +45,8 @@ P3DPythonRun(const char *program_name, const char *archive_file,
_read_thread_continue = false;
_program_continue = true;
_session_terminated = false;
_taskMgr = NULL;
INIT_LOCK(_commands_lock);
INIT_THREAD(_read_thread);
@ -116,7 +118,7 @@ P3DPythonRun(const char *program_name, const char *archive_file,
////////////////////////////////////////////////////////////////////
P3DPythonRun::
~P3DPythonRun() {
nassertv(_instances.empty());
terminate_session();
// Close the write pipe, so the parent process will terminate us.
_pipe_write.close();
@ -1406,14 +1408,18 @@ terminate_session() {
}
_instances.clear();
if (!_session_terminated) {
if (_taskMgr != NULL) {
PyObject *result = PyObject_CallMethod(_taskMgr, (char *)"stop", (char *)"");
if (result == NULL) {
PyErr_Print();
return;
}
} else {
Py_DECREF(result);
}
}
_session_terminated = true;
}
}
////////////////////////////////////////////////////////////////////