diff options
Diffstat (limited to 'sources/pyside6/libpyside/signalmanager.cpp')
-rw-r--r-- | sources/pyside6/libpyside/signalmanager.cpp | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/sources/pyside6/libpyside/signalmanager.cpp b/sources/pyside6/libpyside/signalmanager.cpp index 933edd318..8b7b45546 100644 --- a/sources/pyside6/libpyside/signalmanager.cpp +++ b/sources/pyside6/libpyside/signalmanager.cpp @@ -26,7 +26,9 @@ #include <QtCore/qhash.h> #include <QtCore/qscopedpointer.h> +#include <climits> #include <memory> +#include <utility> using namespace Qt::StringLiterals; @@ -125,6 +127,17 @@ PyObjectWrapper::PyObjectWrapper(const PyObjectWrapper &other) Py_XINCREF(m_me); } +PyObjectWrapper::PyObjectWrapper(PyObjectWrapper &&other) noexcept + : m_me{std::exchange(other.m_me, nullptr)} +{ +} + +PyObjectWrapper &PyObjectWrapper::operator=(PyObjectWrapper &&other) noexcept +{ + m_me = std::exchange(other.m_me, nullptr); + return *this; +} + PyObjectWrapper::~PyObjectWrapper() { // Check that Python is still initialized as sometimes this is called by a static destructor @@ -221,7 +234,29 @@ QDataStream &operator>>(QDataStream &in, PyObjectWrapper &myObj) return in; } -}; +PYSIDE_API QDebug operator<<(QDebug debug, const PyObjectWrapper &myObj) +{ + QDebugStateSaver saver(debug); + debug.noquote(); + debug.nospace(); + // Do not repeat the type name as it is typically called from the QVariant debug + // operator, which outputs the type. + debug << '<'; + if (PyObject *ob = myObj) { + const auto refs = Py_REFCNT(ob); + debug << Py_TYPE(ob)->tp_name << " at " << ob; + if (refs == UINT_MAX) // _Py_IMMORTAL_REFCNT + debug << ", immortal"; + else + debug << ", refs=" << refs; + } else { + debug << '0'; + } + debug << '>'; + return debug; +} + +} // namespace PySide using namespace PySide; |