@@ -238,6 +238,8 @@ void PythonQt::init(int flags, const QByteArray& pythonQtModuleName)
238238 Py_INCREF (obj);
239239 PyModule_AddObject (pack2, enumNames[i], obj);
240240 }
241+
242+ _self->priv ()->pythonQtModule ().addObject (" Debug" , _self->priv ()->_debugAPI );
241243 }
242244}
243245
@@ -314,7 +316,6 @@ PythonQt::PythonQt(int flags, const QByteArray& pythonQtModuleName)
314316 Py_INCREF (&PythonQtStdInRedirectType);
315317
316318 initPythonQtModule (flags & RedirectStdOut, pythonQtModuleName);
317-
318319}
319320
320321PythonQt::~PythonQt () {
@@ -1290,6 +1291,7 @@ PythonQtPrivate::PythonQtPrivate()
12901291 _profilingCB = NULL ;
12911292 _hadError = false ;
12921293 _systemExitExceptionHandlerEnabled = false ;
1294+ _debugAPI = new PythonQtDebugAPI (this );
12931295}
12941296
12951297void PythonQtPrivate::setupSharedLibrarySuffixes ()
@@ -2013,16 +2015,26 @@ QString PythonQtPrivate::getSignature(PyObject* object)
20132015void PythonQtPrivate::shellClassDeleted ( void * shellClass )
20142016{
20152017 PythonQtInstanceWrapper* wrap = _wrappedObjects.value (shellClass);
2016- if (wrap && wrap->_wrappedPtr ) {
2017- // this is a pure C++ wrapper and the shell has gone, so we need
2018- // to set the _wrappedPtr to NULL on the wrapper
2019- wrap->_wrappedPtr = NULL ;
2020- // and then we remove the wrapper, since the wrapped class is gone
2021- _wrappedObjects.remove (shellClass);
2022- }
2023- // if the wrapper is a QObject, we do not handle this here,
2024- // it will be handled by the QPointer<> to the QObject, which becomes NULL
2025- // via the QObject destructor.
2018+ if (wrap) {
2019+ if (wrap->_wrappedPtr ) {
2020+ // this is a pure C++ wrapper and the shell has gone, so we need
2021+ // to set the _wrappedPtr to NULL on the wrapper
2022+ wrap->_wrappedPtr = NULL ;
2023+ // and then we remove the wrapper, since the wrapped class is gone
2024+ _wrappedObjects.remove (shellClass);
2025+ }
2026+ // if the wrapper is a QObject, we do not handle this here,
2027+ // it will be handled by the QPointer<> to the QObject, which becomes NULL
2028+ // via the QObject destructor.
2029+
2030+ // if the shell was owned by C++ and is deleted via C++, we
2031+ // need to decrement the ref-count of the wrapper so that is can
2032+ // be released.
2033+ if (wrap->_shellInstanceRefCountsWrapper ) {
2034+ Py_DECREF ((PyObject*)wrap);
2035+ wrap->_shellInstanceRefCountsWrapper = false ;
2036+ }
2037+ }
20262038}
20272039
20282040PyObject* PythonQtPrivate::wrapMemoryAsBuffer ( const void * data, Py_ssize_t size )
0 commit comments