aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/libpyside
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside2/libpyside')
-rw-r--r--sources/pyside2/libpyside/CMakeLists.txt2
-rw-r--r--sources/pyside2/libpyside/dynamicqmetaobject_p.h2
-rw-r--r--sources/pyside2/libpyside/globalreceiverv2.cpp6
-rw-r--r--sources/pyside2/libpyside/pyside.cpp7
-rw-r--r--sources/pyside2/libpyside/pysideclassinfo_p.h2
-rw-r--r--sources/pyside2/libpyside/pysidesignal.cpp13
-rw-r--r--sources/pyside2/libpyside/pysidestaticstrings.cpp59
-rw-r--r--sources/pyside2/libpyside/pysidestaticstrings.h56
-rw-r--r--sources/pyside2/libpyside/signalmanager.cpp13
9 files changed, 142 insertions, 18 deletions
diff --git a/sources/pyside2/libpyside/CMakeLists.txt b/sources/pyside2/libpyside/CMakeLists.txt
index 7b8adfc84..7493a453a 100644
--- a/sources/pyside2/libpyside/CMakeLists.txt
+++ b/sources/pyside2/libpyside/CMakeLists.txt
@@ -53,6 +53,7 @@ set(libpyside_SRC
pysideqflags.cpp
pysideweakref.cpp
pyside.cpp
+ pysidestaticstrings.cpp
${DESTROYLISTENER_MOC}
)
@@ -130,6 +131,7 @@ set(libpyside_HEADERS
pysidemacros.h
signalmanager.h
pyside.h
+ pysidestaticstrings.h
pysidemetafunction.h
pysidesignal.h
pysideproperty.h
diff --git a/sources/pyside2/libpyside/dynamicqmetaobject_p.h b/sources/pyside2/libpyside/dynamicqmetaobject_p.h
index 534be5825..9199630b7 100644
--- a/sources/pyside2/libpyside/dynamicqmetaobject_p.h
+++ b/sources/pyside2/libpyside/dynamicqmetaobject_p.h
@@ -45,8 +45,6 @@
#include <QtCore/QByteArray>
#include <QtCore/QMetaMethod>
-#define GLOBAL_RECEIVER_CLASS_NAME "__GlobalReceiver__"
-
struct PySideProperty;
namespace PySide
{
diff --git a/sources/pyside2/libpyside/globalreceiverv2.cpp b/sources/pyside2/libpyside/globalreceiverv2.cpp
index 170cbf22f..0377f7697 100644
--- a/sources/pyside2/libpyside/globalreceiverv2.cpp
+++ b/sources/pyside2/libpyside/globalreceiverv2.cpp
@@ -187,7 +187,7 @@ DynamicSlotDataV2::~DynamicSlotDataV2()
GlobalReceiverV2::GlobalReceiverV2(PyObject *callback, SharedMap map) :
QObject(nullptr),
- m_metaObject(GLOBAL_RECEIVER_CLASS_NAME, &QObject::staticMetaObject),
+ m_metaObject("__GlobalReceiver__", &QObject::staticMetaObject),
m_sharedMap(std::move(map))
{
m_data = new DynamicSlotDataV2(callback, this);
@@ -283,7 +283,11 @@ int GlobalReceiverV2::refCount(const QObject *link) const
void GlobalReceiverV2::notify()
{
+#if QT_VERSION >= 0x050E00
+ const QSet<const QObject *> objSet(m_refs.cbegin(), m_refs.cend());
+#else
const auto objSet = QSet<const QObject *>::fromList(m_refs);
+#endif
Py_BEGIN_ALLOW_THREADS
for (const QObject *o : objSet) {
QMetaObject::disconnect(o, DESTROY_SIGNAL_ID, this, DESTROY_SLOT_ID);
diff --git a/sources/pyside2/libpyside/pyside.cpp b/sources/pyside2/libpyside/pyside.cpp
index ffa837a01..2419b2e16 100644
--- a/sources/pyside2/libpyside/pyside.cpp
+++ b/sources/pyside2/libpyside/pyside.cpp
@@ -45,6 +45,7 @@
#include "pysideproperty.h"
#include "pysidesignal.h"
#include "pysidesignal_p.h"
+#include "pysidestaticstrings.h"
#include "pysideslot_p.h"
#include "pysidemetafunction_p.h"
#include "pysidemetafunction.h"
@@ -57,6 +58,7 @@
#include <gilstate.h>
#include <sbkconverter.h>
#include <sbkstring.h>
+#include <sbkstaticstrings.h>
#include <qapp_macro.h>
#include <QtCore/QByteArray>
@@ -234,7 +236,8 @@ void initDynamicMetaObject(SbkObjectType *type, const QMetaObject *base, std::si
if (!converter)
return;
Shiboken::AutoDecRef pyMetaObject(Shiboken::Conversions::pointerToPython(converter, metaObjectPtr));
- PyObject_SetAttrString(reinterpret_cast<PyObject *>(type), "staticMetaObject", pyMetaObject);
+ PyObject_SetAttr(reinterpret_cast<PyObject *>(type),
+ PySide::PyName::qtStaticMetaObject(), pyMetaObject);
}
TypeUserData *retrieveTypeUserData(SbkObjectType *sbkTypeObj)
@@ -540,7 +543,7 @@ bool registerInternalQtConf()
// Querying __file__ should be done only for modules that have finished their initialization.
// Thus querying for the top-level PySide2 package works for us whenever any Qt-wrapped module
// is loaded.
- PyObject *pysideInitFilePath = PyObject_GetAttrString(pysideModule, "__file__");
+ PyObject *pysideInitFilePath = PyObject_GetAttr(pysideModule, Shiboken::PyMagicName::file());
Py_DECREF(pysideModule);
if (!pysideInitFilePath)
return false;
diff --git a/sources/pyside2/libpyside/pysideclassinfo_p.h b/sources/pyside2/libpyside/pysideclassinfo_p.h
index c0038a71a..021aa58e9 100644
--- a/sources/pyside2/libpyside/pysideclassinfo_p.h
+++ b/sources/pyside2/libpyside/pysideclassinfo_p.h
@@ -44,8 +44,6 @@
#include <QMetaObject>
#include "pysideclassinfo.h"
-#define __INFO_ATTR_NAME__ "__classInfo__" // not used! ???
-
struct PySideClassInfo;
extern "C"
diff --git a/sources/pyside2/libpyside/pysidesignal.cpp b/sources/pyside2/libpyside/pysidesignal.cpp
index a09c17a24..ed1dcb729 100644
--- a/sources/pyside2/libpyside/pysidesignal.cpp
+++ b/sources/pyside2/libpyside/pysidesignal.cpp
@@ -40,6 +40,7 @@
#include <sbkpython.h>
#include "pysidesignal.h"
#include "pysidesignal_p.h"
+#include "pysidestaticstrings.h"
#include "signalmanager.h"
#include <shiboken.h>
@@ -412,7 +413,8 @@ PyObject *signalInstanceConnect(PyObject *self, PyObject *args, PyObject *kwds)
if (match) {
Shiboken::AutoDecRef tupleArgs(PyList_AsTuple(pyArgs));
- Shiboken::AutoDecRef pyMethod(PyObject_GetAttrString(source->d->source, "connect"));
+ Shiboken::AutoDecRef pyMethod(PyObject_GetAttr(source->d->source,
+ PySide::PyName::qtConnect()));
if (pyMethod.isNull()) { // PYSIDE-79: check if pyMethod exists.
PyErr_SetString(PyExc_RuntimeError, "method 'connect' vanished!");
return 0;
@@ -465,7 +467,8 @@ PyObject *signalInstanceEmit(PyObject *self, PyObject *args)
for (Py_ssize_t i = 0, max = PyTuple_Size(args); i < max; i++)
PyList_Append(pyArgs, PyTuple_GetItem(args, i));
- Shiboken::AutoDecRef pyMethod(PyObject_GetAttrString(source->d->source, "emit"));
+ Shiboken::AutoDecRef pyMethod(PyObject_GetAttr(source->d->source,
+ PySide::PyName::qtEmit()));
Shiboken::AutoDecRef tupleArgs(PyList_AsTuple(pyArgs));
return PyObject_CallObject(pyMethod, tupleArgs);
@@ -530,7 +533,8 @@ PyObject *signalInstanceDisconnect(PyObject *self, PyObject *args)
if (match) {
Shiboken::AutoDecRef tupleArgs(PyList_AsTuple(pyArgs));
- Shiboken::AutoDecRef pyMethod(PyObject_GetAttrString(source->d->source, "disconnect"));
+ Shiboken::AutoDecRef pyMethod(PyObject_GetAttr(source->d->source,
+ PySide::PyName::qtDisconnect()));
PyObject *result = PyObject_CallObject(pyMethod, tupleArgs);
if (!result || result == Py_True)
return result;
@@ -756,7 +760,8 @@ void instanceInitialize(PySideSignalInstance *self, PyObject *name, PySideSignal
bool connect(PyObject *source, const char *signal, PyObject *callback)
{
- Shiboken::AutoDecRef pyMethod(PyObject_GetAttrString(source, "connect"));
+ Shiboken::AutoDecRef pyMethod(PyObject_GetAttr(source,
+ PySide::PyName::qtConnect()));
if (pyMethod.isNull())
return false;
diff --git a/sources/pyside2/libpyside/pysidestaticstrings.cpp b/sources/pyside2/libpyside/pysidestaticstrings.cpp
new file mode 100644
index 000000000..82e233621
--- /dev/null
+++ b/sources/pyside2/libpyside/pysidestaticstrings.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 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 "pysidestaticstrings.h"
+#include <sbkstring.h>
+
+#define STATIC_STRING_IMPL(funcName, value) \
+PyObject *funcName() \
+{ \
+ static PyObject *const s = Shiboken::String::createStaticString(value); \
+ return s; \
+}
+
+namespace PySide
+{
+namespace PyName
+{
+STATIC_STRING_IMPL(qtStaticMetaObject, "staticMetaObject")
+STATIC_STRING_IMPL(qtConnect, "connect")
+STATIC_STRING_IMPL(qtDisconnect, "disconnect")
+STATIC_STRING_IMPL(qtEmit, "emit")
+} // namespace PyName
+} // namespace PySide
diff --git a/sources/pyside2/libpyside/pysidestaticstrings.h b/sources/pyside2/libpyside/pysidestaticstrings.h
new file mode 100644
index 000000000..1d5700c51
--- /dev/null
+++ b/sources/pyside2/libpyside/pysidestaticstrings.h
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 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 PYSIDESTRINGS_H
+#define PYSIDESTRINGS_H
+
+#include <sbkpython.h>
+
+namespace PySide
+{
+namespace PyName
+{
+PyObject *qtStaticMetaObject();
+PyObject *qtConnect();
+PyObject *qtDisconnect();
+PyObject *qtEmit();
+} // namespace PyName
+} // namespace PySide
+
+#endif // PYSIDESTRINGS_H
diff --git a/sources/pyside2/libpyside/signalmanager.cpp b/sources/pyside2/libpyside/signalmanager.cpp
index 0895cc682..c21a3e565 100644
--- a/sources/pyside2/libpyside/signalmanager.cpp
+++ b/sources/pyside2/libpyside/signalmanager.cpp
@@ -53,6 +53,7 @@
#include <gilstate.h>
#include <sbkconverter.h>
#include <sbkstring.h>
+#include <sbkstaticstrings.h>
#include <QtCore/QDebug>
#include <QtCore/QHash>
@@ -77,8 +78,6 @@
#define PYSIDE_SIGNAL '2'
#include "globalreceiverv2.h"
-#define PYTHON_TYPE "PyObject"
-
namespace {
static PyObject *metaObjectAttr = 0;
@@ -171,7 +170,7 @@ QDataStream &operator<<(QDataStream &out, const PyObjectWrapper &myObj)
Shiboken::GilState gil;
if (!reduce_func) {
Shiboken::AutoDecRef pickleModule(PyImport_ImportModule("pickle"));
- reduce_func = PyObject_GetAttrString(pickleModule, "dumps");
+ reduce_func = PyObject_GetAttr(pickleModule, Shiboken::PyName::dumps());
}
Shiboken::AutoDecRef repr(PyObject_CallFunctionObjArgs(reduce_func, (PyObject *)myObj, NULL));
if (repr.object()) {
@@ -202,7 +201,7 @@ QDataStream &operator>>(QDataStream &in, PyObjectWrapper &myObj)
Shiboken::GilState gil;
if (!eval_func) {
Shiboken::AutoDecRef pickleModule(PyImport_ImportModule("pickle"));
- eval_func = PyObject_GetAttrString(pickleModule, "loads");
+ eval_func = PyObject_GetAttr(pickleModule, Shiboken::PyName::loads());
}
QByteArray repr;
@@ -268,15 +267,15 @@ SignalManager::SignalManager() : m_d(new SignalManagerPrivate)
using namespace Shiboken;
// Register PyObject type to use in queued signal and slot connections
- qRegisterMetaType<PyObjectWrapper>(PYTHON_TYPE);
- qRegisterMetaTypeStreamOperators<PyObjectWrapper>(PYTHON_TYPE);
+ qRegisterMetaType<PyObjectWrapper>("PyObject");
+ qRegisterMetaTypeStreamOperators<PyObjectWrapper>("PyObject");
qRegisterMetaTypeStreamOperators<PyObjectWrapper>("PyObjectWrapper");
qRegisterMetaTypeStreamOperators<PyObjectWrapper>("PySide::PyObjectWrapper");
SbkConverter *converter = Shiboken::Conversions::createConverter(&PyBaseObject_Type, nullptr);
Shiboken::Conversions::setCppPointerToPythonFunction(converter, PyObject_PTR_CppToPython_PyObject);
Shiboken::Conversions::setPythonToCppPointerFunctions(converter, PyObject_PythonToCpp_PyObject_PTR, is_PyObject_PythonToCpp_PyObject_PTR_Convertible);
- Shiboken::Conversions::registerConverterName(converter, PYTHON_TYPE);
+ Shiboken::Conversions::registerConverterName(converter, "PyObject");
Shiboken::Conversions::registerConverterName(converter, "object");
Shiboken::Conversions::registerConverterName(converter, "PyObjectWrapper");
Shiboken::Conversions::registerConverterName(converter, "PySide::PyObjectWrapper");