aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sources/pyside2/libpyside/CMakeLists.txt2
-rw-r--r--sources/pyside2/libpyside/globalreceiver.cpp334
-rw-r--r--sources/pyside2/libpyside/globalreceiver.h81
-rw-r--r--sources/pyside2/libpyside/signalmanager.cpp34
-rw-r--r--sources/pyside2/libpyside/signalmanager.h8
5 files changed, 0 insertions, 459 deletions
diff --git a/sources/pyside2/libpyside/CMakeLists.txt b/sources/pyside2/libpyside/CMakeLists.txt
index 083a20725..101b32e4a 100644
--- a/sources/pyside2/libpyside/CMakeLists.txt
+++ b/sources/pyside2/libpyside/CMakeLists.txt
@@ -44,7 +44,6 @@ set(libpyside_SRC
dynamicqmetaobject.cpp
destroylistener.cpp
signalmanager.cpp
- globalreceiver.cpp
globalreceiverv2.cpp
pysideclassinfo.cpp
pysidemetafunction.cpp
@@ -120,7 +119,6 @@ endif()
set(libpyside_HEADERS
destroylistener.h
dynamicqmetaobject.h
- globalreceiver.h
pysideclassinfo.h
pysidemacros.h
signalmanager.h
diff --git a/sources/pyside2/libpyside/globalreceiver.cpp b/sources/pyside2/libpyside/globalreceiver.cpp
deleted file mode 100644
index 78382f5a4..000000000
--- a/sources/pyside2/libpyside/globalreceiver.cpp
+++ /dev/null
@@ -1,334 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt for Python.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "globalreceiver.h"
-#include "dynamicqmetaobject_p.h"
-#include "pysideweakref.h"
-
-#include <QMetaMethod>
-#include <QDebug>
-#include <QEvent>
-#include <QVector>
-#include <autodecref.h>
-#include <sbkconverter.h>
-#include <gilstate.h>
-
-#include "signalmanager.h"
-
-#define RECEIVER_DESTROYED_SLOT_NAME "__receiverDestroyed__(QObject*)"
-
-namespace PySide
-{
-class DynamicSlotData
-{
- Q_DISABLE_COPY(DynamicSlotData)
- public:
- DynamicSlotData(int id, PyObject* callback, GlobalReceiver* parent);
- void addRef(const QObject* o);
- void decRef(const QObject* o);
- void clear();
- int hasRefTo(const QObject* o) const;
- int refCount() const;
- int id() const;
- PyObject* call(PyObject* args);
- ~DynamicSlotData();
- static void onCallbackDestroyed(void* data);
-
- private:
- int m_id;
- bool m_isMethod;
- PyObject* m_callback;
- PyObject* m_pythonSelf;
- PyObject* m_pyClass;
- PyObject* m_weakRef;
- GlobalReceiver* m_parent;
- QVector<const QObject*> m_refs;
-};
-
-}
-
-using namespace PySide;
-
-DynamicSlotData::DynamicSlotData(int id, PyObject* callback, GlobalReceiver* parent)
- : m_id(id), m_pythonSelf(0), m_pyClass(0), m_weakRef(0), m_parent(parent)
-{
- Shiboken::GilState gil;
-
- m_isMethod = PyMethod_Check(callback);
- if (m_isMethod) {
- //Can not store calback pointe because this will be destroyed at the end of the scope
- //To avoid increment intance reference keep the callback information
- m_callback = PyMethod_GET_FUNCTION(callback);
-#ifdef IS_PY3K
- m_pyClass = 0;
-#else
- m_pyClass = PyMethod_GET_CLASS(callback);
-#endif
-
- m_pythonSelf = PyMethod_GET_SELF(callback);
-
- //monitor class from method lifetime
- m_weakRef = WeakRef::create(m_pythonSelf, DynamicSlotData::onCallbackDestroyed, this);
- } else {
- m_callback = callback;
- Py_INCREF(m_callback);
- }
-}
-
-PyObject* DynamicSlotData::call(PyObject* args)
-{
- PyObject* callback = m_callback;
-
- //create a callback based on method data
- Shiboken::GilState gil;
- if (m_isMethod)
-#ifdef IS_PY3K
- callback = PyMethod_New(callback, m_pythonSelf);
-#else
- callback = PyMethod_New(callback, m_pythonSelf, m_pyClass);
-#endif
-
- PyObject* result = PyObject_CallObject(callback, args);
-
- if (m_isMethod)
- Py_DECREF(callback);
-
- return result;
-}
-
-void DynamicSlotData::addRef(const QObject *o)
-{
- m_refs.append(o);
-}
-
-void DynamicSlotData::decRef(const QObject *o)
-{
- m_refs.removeOne(o);
-}
-
-int DynamicSlotData::refCount() const
-{
- return m_refs.size();
-}
-
-int DynamicSlotData::id() const
-{
- return m_id;
-}
-
-int DynamicSlotData::hasRefTo(const QObject *o) const
-{
- return m_refs.count(o);
-}
-
-void DynamicSlotData::clear()
-{
- Shiboken::GilState gil;
- Py_XDECREF(m_weakRef);
- m_weakRef = 0;
- m_refs.clear();
-}
-
-DynamicSlotData::~DynamicSlotData()
-{
- Shiboken::GilState gil;
- clear();
- if (!m_isMethod)
- Py_DECREF(m_callback);
-}
-
-void DynamicSlotData::onCallbackDestroyed(void *data)
-{
- Shiboken::GilState gil;
- DynamicSlotData* self = reinterpret_cast<DynamicSlotData*>(data);
-
- //Disconnect all sources
- QMetaMethod m = self->m_parent->metaObject()->method(self->m_id);
- QByteArray methodName = QByteArray::number(m.methodType()).append(m.methodSignature());
- const QVector<const QObject*> sources = self->m_refs;
- for (const QObject* src : sources)
- const_cast<QObject*>(src)->disconnect(self->m_parent, methodName);
- self->m_weakRef = 0;
-}
-
-GlobalReceiver::GlobalReceiver()
- : m_metaObject(GLOBAL_RECEIVER_CLASS_NAME, &QObject::staticMetaObject)
-{
- //slot used to be notifyed of object destrouction
- m_metaObject.addSlot(RECEIVER_DESTROYED_SLOT_NAME);
- m_metaObject.update();
- setObjectName(QLatin1String("GLOBAL RECEIVER"));
-}
-
-GlobalReceiver::~GlobalReceiver()
-{
- while(!m_slotReceivers.empty()) {
- DynamicSlotData* data = m_slotReceivers.take(m_slotReceivers.begin().key());
- data->clear();
- delete data;
- }
-}
-
-void GlobalReceiver::connectNotify(QObject* source, int slotId)
-{
- const auto it = m_slotReceivers.constFind(slotId);
- if (it != m_slotReceivers.cend()) {
- DynamicSlotData* data = it.value();
- if (!data->hasRefTo(source))
- QObject::connect(source, SIGNAL(destroyed(QObject*)), this, "1" RECEIVER_DESTROYED_SLOT_NAME);
- data->addRef(source);
- }
-}
-
-void GlobalReceiver::disconnectNotify(QObject* source, int slotId)
-{
- const auto it = m_slotReceivers.constFind(slotId);
- if (it != m_slotReceivers.cend()) {
- DynamicSlotData* data = it.value();
- data->decRef(source);
- if (data->refCount() == 0)
- removeSlot(slotId);
-
- if (!hasConnectionWith(source))
- QObject::disconnect(source, SIGNAL(destroyed(QObject*)), this, "1" RECEIVER_DESTROYED_SLOT_NAME);
- }
-}
-
-const QMetaObject* GlobalReceiver::metaObject() const
-{
- return m_metaObject.update();
-}
-
-int GlobalReceiver::addSlot(const char* slot, PyObject* callback)
-{
- int slotId = m_metaObject.addSlot(slot);
- if (!m_slotReceivers.contains(slotId))
- m_slotReceivers.insert(slotId, new DynamicSlotData(slotId, callback, this));
-
- bool isShortCircuit = true;
- for (int i = 0; slot[i]; ++i) {
- if (slot[i] == '(') {
- isShortCircuit = false;
- break;
- }
- }
-
- if (isShortCircuit)
- m_shortCircuitSlots << slotId;
-
- Q_ASSERT(slotId >= QObject::staticMetaObject.methodCount());
- return slotId;
-}
-
-void GlobalReceiver::removeSlot(int slotId)
-{
- auto it = m_slotReceivers.find(slotId);
- if (it != m_slotReceivers.end()) {
- delete it.value();
- m_slotReceivers.erase(it);
- m_metaObject.removeSlot(slotId);
- m_shortCircuitSlots.remove(slotId);
- }
-}
-
-bool GlobalReceiver::hasConnectionWith(const QObject *object)
-{
- QHash<int, DynamicSlotData*>::iterator i = m_slotReceivers.begin();
- while(i != m_slotReceivers.end()) {
- if (i.value()->hasRefTo(object)) {
- return true;
- }
- i++;
- }
- return false;
-}
-
-int GlobalReceiver::qt_metacall(QMetaObject::Call call, int id, void** args)
-{
- Q_ASSERT(call == QMetaObject::InvokeMetaMethod);
- Q_ASSERT(id >= QObject::staticMetaObject.methodCount());
- QMetaMethod slot = metaObject()->method(id);
- Q_ASSERT(slot.methodType() == QMetaMethod::Slot);
-
- if (strcmp(slot.methodSignature(), RECEIVER_DESTROYED_SLOT_NAME) == 0) {
- QObject *arg = *(QObject**)args[1];
-
- //avoid hash changes during the destruction
- QHash<int, DynamicSlotData*> copy = m_slotReceivers;
- QHash<int, DynamicSlotData*>::iterator i = copy.begin();
- while(i != copy.end()) {
- //Remove all refs
- int refs = i.value()->hasRefTo(arg);
- while(refs) {
- disconnectNotify(arg, i.key());
- refs--;
- }
- i++;
- }
- return -1;
- }
-
- DynamicSlotData* data = m_slotReceivers.value(id);
- if (!data) {
- qWarning() << "Unknown global slot, id:" << id;
- return -1;
- }
-
- Shiboken::GilState gil;
- PyObject* retval = 0;
- if (m_shortCircuitSlots.contains(id)) {
- retval = data->call(reinterpret_cast<PyObject*>(args[1]));
- } else {
- QList<QByteArray> paramTypes = slot.parameterTypes();
- Shiboken::AutoDecRef preparedArgs(PyTuple_New(paramTypes.count()));
- for (int i = 0, max = paramTypes.count(); i < max; ++i) {
- const QByteArray& paramType = paramTypes[i];
- Shiboken::Conversions::SpecificConverter converter(paramType.constData());
- PyTuple_SET_ITEM(preparedArgs.object(), i, converter.toPython(args[i+1]));
- }
- retval = data->call(preparedArgs);
- }
-
- if (!retval)
- PyErr_Print();
- else
- Py_DECREF(retval);
-
- return -1;
-}
diff --git a/sources/pyside2/libpyside/globalreceiver.h b/sources/pyside2/libpyside/globalreceiver.h
deleted file mode 100644
index 8fbe2fe78..000000000
--- a/sources/pyside2/libpyside/globalreceiver.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt for Python.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef GLOBALRECEIVER_H
-#define GLOBALRECEIVER_H
-
-#include <sbkpython.h>
-#include <QObject>
-#include <QHash>
-#include <QSet>
-#include "dynamicqmetaobject.h"
-
-namespace PySide
-{
-
-class DynamicSlotData;
-
-class GlobalReceiver : public QObject
-{
-public:
- GlobalReceiver();
- ~GlobalReceiver() override;
-
- int qt_metacall(QMetaObject::Call call, int id, void** args) override;
- const QMetaObject* metaObject() const override;
- int addSlot(const char* slot, PyObject* callback);
- void removeSlot(int slotId);
- void connectNotify(QObject* sender, int slotId);
- void disconnectNotify(QObject* sender, int slotId);
- bool hasConnectionWith(const QObject* object);
-
-protected:
- using QObject::connectNotify;
- using QObject::disconnectNotify;
-
-private:
- DynamicQMetaObject m_metaObject;
- QSet<int> m_shortCircuitSlots;
- QHash<int, DynamicSlotData* > m_slotReceivers;
-};
-
-}
-
-#endif
-
diff --git a/sources/pyside2/libpyside/signalmanager.cpp b/sources/pyside2/libpyside/signalmanager.cpp
index 19779be5b..f624fe7a7 100644
--- a/sources/pyside2/libpyside/signalmanager.cpp
+++ b/sources/pyside2/libpyside/signalmanager.cpp
@@ -77,7 +77,6 @@
#define PYSIDE_SLOT '1'
#define PYSIDE_SIGNAL '2'
#include "globalreceiverv2.h"
-#include "globalreceiver.h"
#define PYTHON_TYPE "PyObject"
@@ -225,9 +224,6 @@ struct SignalManager::SignalManagerPrivate
{
SharedMap m_globalReceivers;
- //Deprecated
- GlobalReceiver m_globalReceiver;
-
SignalManagerPrivate()
{
m_globalReceivers = SharedMap( new QMap<QByteArray, GlobalReceiverV2*>() );
@@ -309,31 +305,6 @@ SignalManager& SignalManager::instance()
return me;
}
-QObject* SignalManager::globalReceiver()
-{
- return &m_d->m_globalReceiver;
-}
-
-void SignalManager::globalReceiverConnectNotify(QObject* source, int slotIndex)
-{
- m_d->m_globalReceiver.connectNotify(source, slotIndex);
-}
-
-void SignalManager::globalReceiverDisconnectNotify(QObject* source, int slotIndex)
-{
- m_d->m_globalReceiver.disconnectNotify(source, slotIndex);
-}
-
-void SignalManager::addGlobalSlot(const char* slot, PyObject* callback)
-{
- m_d->m_globalReceiver.addSlot(slot, callback);
-}
-
-int SignalManager::addGlobalSlotGetIndex(const char* slot, PyObject* callback)
-{
- return m_d->m_globalReceiver.addSlot(slot, callback);
-}
-
QObject* SignalManager::globalReceiver(QObject *sender, PyObject *callback)
{
SharedMap globalReceivers = m_d->m_globalReceivers;
@@ -623,11 +594,6 @@ int SignalManager::registerMetaMethodGetIndex(QObject* source, const char* signa
return methodIndex;
}
-bool SignalManager::hasConnectionWith(const QObject *object)
-{
- return m_d->m_globalReceiver.hasConnectionWith(object);
-}
-
const QMetaObject* SignalManager::retrieveMetaObject(PyObject *self)
{
Shiboken::GilState gil;
diff --git a/sources/pyside2/libpyside/signalmanager.h b/sources/pyside2/libpyside/signalmanager.h
index 745c1e55a..904c2f11a 100644
--- a/sources/pyside2/libpyside/signalmanager.h
+++ b/sources/pyside2/libpyside/signalmanager.h
@@ -103,14 +103,6 @@ public:
// Utility function to call a python method usign args received in qt_metacall
static int callPythonMetaMethod(const QMetaMethod& method, void** args, PyObject* obj, bool isShortCuit);
- PYSIDE_DEPRECATED(QObject* globalReceiver());
- PYSIDE_DEPRECATED(void addGlobalSlot(const char* slot, PyObject* callback));
- PYSIDE_DEPRECATED(int addGlobalSlotGetIndex(const char* slot, PyObject* callback));
-
- PYSIDE_DEPRECATED(void globalReceiverConnectNotify(QObject *sender, int slotIndex));
- PYSIDE_DEPRECATED(void globalReceiverDisconnectNotify(QObject *sender, int slotIndex));
- PYSIDE_DEPRECATED(bool hasConnectionWith(const QObject *object));
-
private:
struct SignalManagerPrivate;
SignalManagerPrivate* m_d;