Changeset 69588 in vbox for trunk/src/libs/xpcom18a4/python
- Timestamp:
- Nov 5, 2017 10:45:32 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/xpcom18a4/python/src/module/_xpcom.cpp
r59809 r69588 76 76 #ifdef VBOX_PYXPCOM 77 77 # include <iprt/cdefs.h> 78 # include <VBox/com/com.h> 78 79 # ifndef MODULE_NAME_SUFFIX 79 80 # define MANGLE_MODULE_NAME(a_szName) a_szName … … 618 619 } 619 620 620 static voiddeinitVBoxPython();621 static nsresult deinitVBoxPython(); 621 622 622 623 static PyObject* 623 624 PyXPCOMMethod_DeinitCOM(PyObject *self, PyObject *args) 624 625 { 626 nsresult nr; 625 627 Py_BEGIN_ALLOW_THREADS; 626 deinitVBoxPython();628 nr = deinitVBoxPython(); 627 629 Py_END_ALLOW_THREADS; 628 return PyInt_FromLong( 0);630 return PyInt_FromLong(nr); 629 631 } 630 632 … … 727 729 {"GetVariantValue", PyXPCOMMethod_GetVariantValue, 1}, 728 730 #ifdef VBOX 729 730 731 732 733 731 {"WaitForEvents", PyXPCOMMethod_WaitForEvents, 1}, 732 {"InterruptWait", PyXPCOMMethod_InterruptWait, 1}, 733 {"DeinitCOM", PyXPCOMMethod_DeinitCOM, 1}, 734 {"AttachThread", PyXPCOMMethod_AttachThread, 1}, 735 {"DetachThread", PyXPCOMMethod_DetachThread, 1}, 734 736 #endif 735 737 #ifdef VBOX_DEBUG_LIFETIMES … … 854 856 855 857 #ifdef VBOX_PYXPCOM 856 # include <VBox/com/com.h>858 # include <VBox/com/com.h> 857 859 using namespace com; 858 860 859 #include <iprt/initterm.h> 860 #include <iprt/string.h> 861 #include <iprt/alloca.h> 862 #include <iprt/stream.h> 863 864 #if PY_MAJOR_VERSION <= 2 861 # include <iprt/initterm.h> 862 # include <iprt/string.h> 863 # include <iprt/alloca.h> 864 # include <iprt/stream.h> 865 866 /** Set if NS_ShutdownXPCOM has been called successfully already and we don't 867 * need to do it again during module termination. This avoids assertion in the 868 * VBoxCOM glue code. */ 869 static bool g_fComShutdownAlready = true; 870 871 # if PY_MAJOR_VERSION <= 2 865 872 extern "C" NS_EXPORT 866 873 void 867 # else874 # else 868 875 /** @todo r=klaus this is hacky, but as Python3 doesn't deal with ELF 869 876 * visibility, assuming that all globals are visible (which is ugly and not 870 877 * true in our case). */ 871 # undef PyMODINIT_FUNC872 # define PyMODINIT_FUNC extern "C" NS_EXPORT PyObject*878 # undef PyMODINIT_FUNC 879 # define PyMODINIT_FUNC extern "C" NS_EXPORT PyObject* 873 880 PyMODINIT_FUNC 874 # endif881 # endif 875 882 initVBoxPython() { /* NOTE! This name is redefined at the top of the file! */ 876 883 static bool s_vboxInited = false; 877 884 if (!s_vboxInited) { 878 int rc = 0; 879 880 # if defined(VBOX_PATH_APP_PRIVATE_ARCH) && defined(VBOX_PATH_SHARED_LIBS)885 int rc = 0; /* Error handling in this code is NON-EXISTING. Sigh. */ 886 887 # if defined(VBOX_PATH_APP_PRIVATE_ARCH) && defined(VBOX_PATH_SHARED_LIBS) 881 888 rc = RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE); 882 # else889 # else 883 890 const char *home = getenv("VBOX_PROGRAM_PATH"); 884 891 if (home) { … … 891 898 rc = RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE); 892 899 } 893 # endif900 # endif 894 901 895 902 rc = com::Initialize(); 896 897 #if PY_MAJOR_VERSION <= 2 903 g_fComShutdownAlready = false; 904 905 # if PY_MAJOR_VERSION <= 2 898 906 init_xpcom(); 899 # else907 # else 900 908 return init_xpcom(); 901 # endif909 # endif 902 910 } 903 # if PY_MAJOR_VERSION >= 3911 # if PY_MAJOR_VERSION >= 3 904 912 return NULL; 905 # endif913 # endif 906 914 } 907 915 908 916 static 909 void deinitVBoxPython() 910 { 911 com::Shutdown(); 917 nsresult deinitVBoxPython() 918 { 919 nsresult nr; 920 if (!g_fComShutdownAlready) 921 { 922 nr = com::Shutdown(); 923 if (!NS_FAILED(nr)) 924 g_fComShutdownAlready = true; 925 } 926 else 927 nr = NS_ERROR_NOT_INITIALIZED; 928 return nr; 912 929 } 913 930
Note:
See TracChangeset
for help on using the changeset viewer.