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