aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel B. Mohler <jmohler@gamry.com>2013-07-11 11:40:05 -0400
committerJohn Ehresman <jpe@wingware.com>2013-07-12 23:46:50 +0200
commit817a5c9bd39d3a22e2a7db9aa497059be57d58d7 (patch)
tree26ebd3cad8230c71858ecd451e3aa63847fbe692
parentc78e245477852092fd9231061b521ce03d8aafcd (diff)
add diagnostics and fallbacks for frozen distributions
Change-Id: I519c912999283bf7e07f8d34201f9e67c7d6216e Reviewed-by: Roman Lacko <backup.rlacko@gmail.com> Reviewed-by: John Ehresman <jpe@wingware.com>
-rw-r--r--PySide/QtCore/typesystem_core_common.xml24
-rw-r--r--PySide/_utils.py.in14
2 files changed, 30 insertions, 8 deletions
diff --git a/PySide/QtCore/typesystem_core_common.xml b/PySide/QtCore/typesystem_core_common.xml
index 76de84908..e40b845c7 100644
--- a/PySide/QtCore/typesystem_core_common.xml
+++ b/PySide/QtCore/typesystem_core_common.xml
@@ -919,13 +919,25 @@
<inject-code class="target" position="end">
{ // Avoid name clash
+ Shiboken::AutoDecRef regFunc((PyObject*)NULL);
Shiboken::AutoDecRef atexit(Shiboken::Module::import("atexit"));
- Shiboken::AutoDecRef regFunc(PyObject_GetAttrString(atexit, "register"));
- PyObject* shutDownFunc = PyObject_GetAttrString(module, "__moduleShutdown");
- Shiboken::AutoDecRef args(PyTuple_New(1));
- PyTuple_SET_ITEM(args, 0, shutDownFunc);
- Shiboken::AutoDecRef retval(PyObject_Call(regFunc, args, 0));
- Q_ASSERT(!retval.isNull());
+ if (atexit.isNull()) {
+ qWarning() &lt;&lt; "Module atexit not found for registering __moduleShutdown";
+ PyErr_Clear();
+ }else{
+ regFunc = PyObject_GetAttrString(atexit, "register");
+ if (regFunc.isNull()) {
+ qWarning() &lt;&lt; "Function atexit.register not found for registering __moduleShutdown";
+ PyErr_Clear();
+ }
+ }
+ if (!atexit.isNull() &amp;&amp; !regFunc.isNull()){
+ PyObject* shutDownFunc = PyObject_GetAttrString(module, "__moduleShutdown");
+ Shiboken::AutoDecRef args(PyTuple_New(1));
+ PyTuple_SET_ITEM(args, 0, shutDownFunc);
+ Shiboken::AutoDecRef retval(PyObject_Call(regFunc, args, 0));
+ Q_ASSERT(!retval.isNull());
+ }
}
</inject-code>
diff --git a/PySide/_utils.py.in b/PySide/_utils.py.in
index 2d3ce69af..b2fdd9306 100644
--- a/PySide/_utils.py.in
+++ b/PySide/_utils.py.in
@@ -84,8 +84,18 @@ if sys.platform == 'win32':
return path
def get_pyside_dir():
- return _get_win32_case_sensitive_name(os.path.abspath(os.path.dirname(__file__)))
+ try:
+ from . import QtCore
+ except ImportError:
+ return _get_win32_case_sensitive_name(os.path.abspath(os.path.dirname(__file__)))
+ else:
+ return _get_win32_case_sensitive_name(os.path.abspath(os.path.dirname(QtCore.__file__)))
else:
def get_pyside_dir():
- return os.path.abspath(os.path.dirname(__file__))
+ try:
+ from . import QtCore
+ except ImportError:
+ return os.path.abspath(os.path.dirname(__file__))
+ else:
+ return os.path.abspath(os.path.dirname(QtCore.__file__))