aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sources/pyside6/libpyside/class_property.cpp8
-rw-r--r--sources/pyside6/libpyside/dynamicqmetaobject.cpp24
-rw-r--r--sources/pyside6/libpyside/feature_select.cpp23
-rw-r--r--sources/pyside6/libpyside/globalreceiverv2.cpp10
-rw-r--r--sources/pyside6/libpyside/pyside.cpp75
-rw-r--r--sources/pyside6/libpyside/pysideclassdecorator.cpp2
-rw-r--r--sources/pyside6/libpyside/pysideclassdecorator_p.h8
-rw-r--r--sources/pyside6/libpyside/pysideclassinfo.cpp2
-rw-r--r--sources/pyside6/libpyside/pysidemetafunction.cpp10
-rw-r--r--sources/pyside6/libpyside/pysideproperty.cpp54
-rw-r--r--sources/pyside6/libpyside/pysideproperty_p.h2
-rw-r--r--sources/pyside6/libpyside/pysideqenum.cpp10
-rw-r--r--sources/pyside6/libpyside/pysidesignal.cpp69
-rw-r--r--sources/pyside6/libpyside/pysideslot.cpp4
-rw-r--r--sources/pyside6/libpyside/pysideweakref.cpp2
-rw-r--r--sources/pyside6/libpyside/qobjectconnect.cpp13
-rw-r--r--sources/pyside6/libpyside/signalmanager.cpp20
-rw-r--r--sources/pyside6/libpyside/signalmanager.h4
18 files changed, 175 insertions, 165 deletions
diff --git a/sources/pyside6/libpyside/class_property.cpp b/sources/pyside6/libpyside/class_property.cpp
index 2bed97ef5..9be7dccb0 100644
--- a/sources/pyside6/libpyside/class_property.cpp
+++ b/sources/pyside6/libpyside/class_property.cpp
@@ -79,7 +79,7 @@ PyTypeObject *PyClassPropertyType_TypeF()
// We call `__init__` while pretending to be a PyProperty_Type instance.
static int PyClassProperty_tp_init(PyObject *self, PyObject *args, PyObject *kwargs)
{
- auto hold = Py_TYPE(self);
+ auto *hold = Py_TYPE(self);
self->ob_type = &PyProperty_Type;
auto ret = PepExt_Type_GetInitSlot(&PyProperty_Type)(self, args, kwargs);
self->ob_type = hold;
@@ -126,7 +126,7 @@ static int SbkObjectType_meta_setattro(PyObject *obj, PyObject *name, PyObject *
{
// Use `_PepType_Lookup()` instead of `PyObject_GetAttr()` in order to get the raw
// descriptor (`property`) instead of calling `tp_descr_get` (`property.__get__()`).
- auto type = reinterpret_cast<PyTypeObject *>(obj);
+ auto *type = reinterpret_cast<PyTypeObject *>(obj);
PySide::Feature::Select(type);
PyObject *descr = _PepType_Lookup(type, name);
@@ -134,7 +134,7 @@ static int SbkObjectType_meta_setattro(PyObject *obj, PyObject *name, PyObject *
// 1. `Type.class_prop = value` --> descr_set: `Type.class_prop.__set__(value)`
// 2. `Type.class_prop = other_class_prop` --> setattro: replace existing `class_prop`
// 3. `Type.regular_attribute = value` --> setattro: regular attribute assignment
- const auto class_prop = reinterpret_cast<PyObject *>(PyClassProperty_TypeF());
+ auto *class_prop = reinterpret_cast<PyObject *>(PyClassProperty_TypeF());
const auto call_descr_set = descr && PyObject_IsInstance(descr, class_prop)
&& !PyObject_IsInstance(value, class_prop);
if (call_descr_set) {
@@ -171,7 +171,7 @@ void init(PyObject *module)
return;
Py_INCREF(PyClassProperty_TypeF());
- auto classproptype = reinterpret_cast<PyObject *>(PyClassProperty_TypeF());
+ auto *classproptype = reinterpret_cast<PyObject *>(PyClassProperty_TypeF());
PyModule_AddObject(module, "PyClassProperty", classproptype);
}
diff --git a/sources/pyside6/libpyside/dynamicqmetaobject.cpp b/sources/pyside6/libpyside/dynamicqmetaobject.cpp
index 048001f81..eda3cee09 100644
--- a/sources/pyside6/libpyside/dynamicqmetaobject.cpp
+++ b/sources/pyside6/libpyside/dynamicqmetaobject.cpp
@@ -116,7 +116,7 @@ MetaObjectBuilder::MetaObjectBuilder(PyTypeObject *type, const QMetaObject *meta
MetaObjectBuilder::~MetaObjectBuilder()
{
- for (auto *metaObject : m_d->m_cachedMetaObjects)
+ for (const auto *metaObject : m_d->m_cachedMetaObjects)
free(const_cast<QMetaObject*>(metaObject));
delete m_d->m_builder;
delete m_d;
@@ -249,7 +249,7 @@ void MetaObjectBuilderPrivate::removeMethod(QMetaMethod::MethodType mtype,
int index)
{
index -= m_baseObject->methodCount();
- auto builder = ensureBuilder();
+ auto *builder = ensureBuilder();
Q_ASSERT(index >= 0 && index < builder->methodCount());
switch (mtype) {
case QMetaMethod::Constructor:
@@ -351,7 +351,7 @@ void MetaObjectBuilder::addInfo(const char *key, const char *value)
void MetaObjectBuilderPrivate::addInfo(const QMap<QByteArray, QByteArray> &info)
{
- auto builder = ensureBuilder();
+ auto *builder = ensureBuilder();
for (auto i = info.constBegin(), end = info.constEnd(); i != end; ++i)
builder->addClassInfo(i.key(), i.value());
m_dirty = true;
@@ -371,7 +371,7 @@ void MetaObjectBuilder::addEnumerator(const char *name, bool flag, bool scoped,
void MetaObjectBuilderPrivate::addEnumerator(const char *name, bool flag, bool scoped,
const MetaObjectBuilder::EnumValues &entries)
{
- auto builder = ensureBuilder();
+ auto *builder = ensureBuilder();
int have_already = builder->indexOfEnumerator(name);
if (have_already >= 0)
builder->removeEnumerator(have_already);
@@ -387,7 +387,7 @@ void MetaObjectBuilderPrivate::addEnumerator(const char *name, bool flag, bool s
void MetaObjectBuilderPrivate::removeProperty(int index)
{
index -= m_baseObject->propertyCount();
- auto builder = ensureBuilder();
+ auto *builder = ensureBuilder();
Q_ASSERT(index >= 0 && index < builder->propertyCount());
builder->removeProperty(index);
m_dirty = true;
@@ -517,7 +517,7 @@ QString MetaObjectBuilder::formatMetaObject(const QMetaObject *metaObject)
QTextStream str(&result);
str << "PySide" << QT_VERSION_MAJOR << ".QtCore.QMetaObject(\""
<< metaObject->className() << '"';
- if (auto *s = metaObject->superClass())
+ if (const auto *s = metaObject->superClass())
str << " inherits \"" << s->className() << '"';
str << ":\n";
@@ -572,13 +572,13 @@ void MetaObjectBuilderPrivate::parsePythonType(PyTypeObject *type)
std::vector<PyTypeObject *> basesToCheck;
// Prepend the actual type that we are parsing.
- basesToCheck.reserve(1u + basesCount);
+ basesToCheck.reserve(1U + basesCount);
basesToCheck.push_back(type);
- auto sbkObjTypeF = SbkObject_TypeF();
- auto baseObjType = reinterpret_cast<PyTypeObject *>(&PyBaseObject_Type);
+ auto *sbkObjTypeF = SbkObject_TypeF();
+ auto *baseObjType = reinterpret_cast<PyTypeObject *>(&PyBaseObject_Type);
for (Py_ssize_t i = 0; i < basesCount; ++i) {
- auto baseType = reinterpret_cast<PyTypeObject *>(PyTuple_GET_ITEM(mro, i));
+ auto *baseType = reinterpret_cast<PyTypeObject *>(PyTuple_GET_ITEM(mro, i));
if (baseType != sbkObjTypeF && baseType != baseObjType
&& !PySide::isQObjectDerived(baseType, false)) {
basesToCheck.push_back(baseType);
@@ -655,7 +655,7 @@ void MetaObjectBuilderPrivate::parsePythonType(PyTypeObject *type)
AutoDecRef obName(PyObject_GetAttr(obEnumType, PyMagicName::name()));
// Everything has been checked already in resolveDelayedQEnums.
// Therefore, we don't need to error-check here again.
- auto name = String::toCString(obName);
+ const auto *name = String::toCString(obName);
AutoDecRef members(PyObject_GetAttr(obEnumType, PyMagicName::members()));
AutoDecRef items(PyMapping_Items(members));
Py_ssize_t nr_items = PySequence_Length(items);
@@ -666,7 +666,7 @@ void MetaObjectBuilderPrivate::parsePythonType(PyTypeObject *type)
AutoDecRef key(PySequence_GetItem(item, 0));
AutoDecRef member(PySequence_GetItem(item, 1));
AutoDecRef value(PyObject_GetAttr(member, Shiboken::PyName::value()));
- auto ckey = String::toCString(key);
+ const auto *ckey = String::toCString(key);
auto ivalue = PyLong_AsSsize_t(value);
entries.push_back(std::make_pair(ckey, int(ivalue)));
}
diff --git a/sources/pyside6/libpyside/feature_select.cpp b/sources/pyside6/libpyside/feature_select.cpp
index cfd465267..3d61f148f 100644
--- a/sources/pyside6/libpyside/feature_select.cpp
+++ b/sources/pyside6/libpyside/feature_select.cpp
@@ -192,7 +192,7 @@ static bool addNewDict(PyTypeObject *type, int select_id)
return false;
setSelectId(new_dict, select_id);
// insert the dict into the ring
- auto next_dict = nextInCircle(dict);
+ auto *next_dict = nextInCircle(dict);
setNextDict(dict, new_dict);
setNextDict(new_dict, next_dict);
PepType_SetDict(type, new_dict);
@@ -347,9 +347,9 @@ static inline void SelectFeatureSet(PyTypeObject *type)
last_select_id = select_id;
auto *mro = type->tp_mro;
- Py_ssize_t idx, n = PyTuple_GET_SIZE(mro);
+ const Py_ssize_t n = PyTuple_GET_SIZE(mro);
// We leave 'Shiboken.Object' and 'object' alone, therefore "n - 2".
- for (idx = 0; idx < n - 2; idx++) {
+ for (Py_ssize_t idx = 0; idx < n - 2; idx++) {
auto *sub_type = reinterpret_cast<PyTypeObject *>(PyTuple_GET_ITEM(mro, idx));
SelectFeatureSetSubtype(sub_type, select_id);
}
@@ -444,10 +444,10 @@ static PyObject *methodWithNewName(PyTypeObject *type,
* Create a method with a lower case name.
*/
auto *obtype = reinterpret_cast<PyObject *>(type);
- int len = strlen(new_name);
- auto name = new char[len + 1];
+ const auto len = strlen(new_name);
+ auto *name = new char[len + 1];
strcpy(name, new_name);
- auto new_meth = new PyMethodDef;
+ auto *new_meth = new PyMethodDef;
new_meth->ml_name = name;
new_meth->ml_meth = meth->ml_meth;
new_meth->ml_flags = meth->ml_flags;
@@ -479,7 +479,8 @@ static bool feature_01_addLowerNames(PyTypeObject *type, PyObject *prev_dict, in
/*
* Add objects with lower names to `type->tp_dict` from 'prev_dict`.
*/
- PyObject *key, *value;
+ PyObject *key{};
+ PyObject *value{};
Py_ssize_t pos = 0;
// We first copy the things over which will not be changed:
@@ -555,7 +556,7 @@ static PyObject *createProperty(PyTypeObject *type, PyObject *getter, PyObject *
return prop;
}
-static const QByteArrayList parseFields(const char *propStr, bool *stdWrite)
+static QByteArrayList parseFields(const char *propStr, bool *stdWrite)
{
/*
* Break the string into subfields at ':' and add defaults.
@@ -630,7 +631,7 @@ static QByteArrayList GetPropertyStringsMro(PyTypeObject *type)
// We leave 'Shiboken.Object' and 'object' alone, therefore "n - 2".
for (Py_ssize_t idx = 0; idx < n - 2; idx++) {
auto *subType = reinterpret_cast<PyTypeObject *>(PyTuple_GET_ITEM(mro, idx));
- auto props = SbkObjectType_GetPropertyStrings(subType);
+ auto *props = SbkObjectType_GetPropertyStrings(subType);
if (props != nullptr)
for (; *props != nullptr; ++props)
res << QByteArray(*props);
@@ -673,7 +674,7 @@ static bool feature_02_true_property(PyTypeObject *type, PyObject *prev_dict, in
return true;
for (const auto &propStr : std::as_const(props)) {
- bool isStdWrite;
+ bool isStdWrite{};
auto fields = parseFields(propStr, &isStdWrite);
bool haveWrite = fields.size() == 3;
PyObject *name = make_snake_case(fields[0], lower);
@@ -758,7 +759,7 @@ static PyGetSetDef property_getset[] = {
static bool patch_property_impl()
{
// Turn `__doc__` into a computed attribute without changing writability.
- auto gsp = property_getset;
+ auto *gsp = property_getset;
auto *type = &PyProperty_Type;
AutoDecRef dict(PepType_GetDict(type));
AutoDecRef descr(PyDescr_NewGetSet(type, gsp));
diff --git a/sources/pyside6/libpyside/globalreceiverv2.cpp b/sources/pyside6/libpyside/globalreceiverv2.cpp
index 2c75e39e1..7bb1a7b7f 100644
--- a/sources/pyside6/libpyside/globalreceiverv2.cpp
+++ b/sources/pyside6/libpyside/globalreceiverv2.cpp
@@ -17,9 +17,6 @@
#include <cstring>
-#define RECEIVER_DESTROYED_SLOT_NAME "__receiverDestroyed__(QObject*)"
-
-
namespace PySide
{
@@ -121,7 +118,8 @@ GlobalReceiverKey DynamicSlotDataV2::key(PyObject *callback)
if (PyMethod_Check(callback)) {
// PYSIDE-1422: Avoid hash on self which might be unhashable.
return {PyMethod_GET_SELF(callback), PyMethod_GET_FUNCTION(callback)};
- } else if (PySide::isCompiledMethod(callback)) {
+ }
+ if (PySide::isCompiledMethod(callback)) {
// PYSIDE-1589: Fix for slots in compiled functions
Shiboken::AutoDecRef self(PyObject_GetAttr(callback, PySide::PySideName::im_self()));
Shiboken::AutoDecRef func(PyObject_GetAttr(callback, PySide::PySideName::im_func()));
@@ -159,10 +157,10 @@ int DynamicSlotDataV2::addSlot(const char *signature)
void DynamicSlotDataV2::onCallbackDestroyed(void *data)
{
- auto self = reinterpret_cast<DynamicSlotDataV2 *>(data);
+ auto *self = reinterpret_cast<DynamicSlotDataV2 *>(data);
self->m_weakRef = nullptr;
Py_BEGIN_ALLOW_THREADS
- SignalManager::instance().deleteGlobalReceiver(self->m_parent);
+ SignalManager::deleteGlobalReceiver(self->m_parent);
Py_END_ALLOW_THREADS
}
diff --git a/sources/pyside6/libpyside/pyside.cpp b/sources/pyside6/libpyside/pyside.cpp
index 9e12e3cd7..e4938d486 100644
--- a/sources/pyside6/libpyside/pyside.cpp
+++ b/sources/pyside6/libpyside/pyside.cpp
@@ -218,10 +218,10 @@ static QByteArrayList _SbkType_LookupProperty(PyTypeObject *type,
auto n = PyTuple_GET_SIZE(mro);
auto len = std::strlen(origName);
for (Py_ssize_t idx = 0; idx < n; idx++) {
- PyTypeObject *base = reinterpret_cast<PyTypeObject *>(PyTuple_GET_ITEM(mro, idx));
+ auto *base = reinterpret_cast<PyTypeObject *>(PyTuple_GET_ITEM(mro, idx));
if (!SbkObjectType_Check(base))
continue;
- auto props = SbkObjectType_GetPropertyStrings(base);
+ auto *props = SbkObjectType_GetPropertyStrings(base);
if (props == nullptr || *props == nullptr)
continue;
for (; *props != nullptr; ++props) {
@@ -255,11 +255,12 @@ static bool _setProperty(PyObject *qObj, PyObject *name, PyObject *value, bool *
using Shiboken::AutoDecRef;
QByteArray propName(Shiboken::String::toCString(name));
- auto type = Py_TYPE(qObj);
+ auto *type = Py_TYPE(qObj);
int flags = currentSelectId(type);
int prop_flag = flags & 0x02;
auto found = false;
- QByteArray getterName{}, setterName{};
+ QByteArray getterName;
+ QByteArray setterName;
auto fields = _SbkType_LookupProperty(type, propName, flags);
if (!fields.isEmpty()) {
@@ -331,7 +332,7 @@ static std::optional<QMetaMethod> findSignal(const QMetaObject *mo,
if (method.methodType() == QMetaMethod::Signal && method.name() == name)
return method;
}
- auto *base = mo->superClass();
+ const auto *base = mo->superClass();
return base != nullptr ? findSignal(base, name) : std::nullopt;
}
@@ -339,7 +340,8 @@ bool fillQtProperties(PyObject *qObj, const QMetaObject *metaObj,
PyObject *kwds, bool allowErrors)
{
- PyObject *key, *value;
+ PyObject *key{};
+ PyObject *value{};
Py_ssize_t pos = 0;
int flags = currentSelectId(Py_TYPE(qObj));
int snake_flag = flags & 0x01;
@@ -396,9 +398,9 @@ void runCleanupFunctions()
static void destructionVisitor(SbkObject *pyObj, void *data)
{
- auto realData = reinterpret_cast<void **>(data);
- auto pyQApp = reinterpret_cast<SbkObject *>(realData[0]);
- auto pyQObjectType = reinterpret_cast<PyTypeObject *>(realData[1]);
+ auto *realData = reinterpret_cast<void **>(data);
+ auto *pyQApp = reinterpret_cast<SbkObject *>(realData[0]);
+ auto *pyQObjectType = reinterpret_cast<PyTypeObject *>(realData[1]);
if (pyObj != pyQApp && PyObject_TypeCheck(pyObj, pyQObjectType)) {
if (Shiboken::Object::hasOwnership(pyObj) && Shiboken::Object::isValid(pyObj, false)) {
@@ -446,7 +448,7 @@ std::size_t getSizeOfQObject(PyTypeObject *type)
void initDynamicMetaObject(PyTypeObject *type, const QMetaObject *base, std::size_t cppObjSize)
{
//create DynamicMetaObject based on python type
- auto userData = new TypeUserData(reinterpret_cast<PyTypeObject *>(type), base, cppObjSize);
+ auto *userData = new TypeUserData(reinterpret_cast<PyTypeObject *>(type), base, cppObjSize);
userData->mo.update();
Shiboken::ObjectType::setTypeUserData(type, userData, Shiboken::callCppDestructor<TypeUserData>);
@@ -469,7 +471,7 @@ TypeUserData *retrieveTypeUserData(PyTypeObject *pyTypeObj)
TypeUserData *retrieveTypeUserData(PyObject *pyObj)
{
- auto pyTypeObj = PyType_Check(pyObj)
+ auto *pyTypeObj = PyType_Check(pyObj)
? reinterpret_cast<PyTypeObject *>(pyObj) : Py_TYPE(pyObj);
return retrieveTypeUserData(pyTypeObj);
}
@@ -482,7 +484,7 @@ const QMetaObject *retrieveMetaObject(PyTypeObject *pyTypeObj)
const QMetaObject *retrieveMetaObject(PyObject *pyObj)
{
- auto pyTypeObj = PyType_Check(pyObj)
+ auto *pyTypeObj = PyType_Check(pyObj)
? reinterpret_cast<PyTypeObject *>(pyObj) : Py_TYPE(pyObj);
return retrieveMetaObject(pyTypeObj);
}
@@ -497,7 +499,7 @@ void initQObjectSubType(PyTypeObject *type, PyObject *args, PyObject * /* kwds *
TypeUserData *userData = nullptr;
for (int i = 0; i < numBases; ++i) {
- auto base = reinterpret_cast<PyTypeObject *>(PyTuple_GET_ITEM(bases, i));
+ auto *base = reinterpret_cast<PyTypeObject *>(PyTuple_GET_ITEM(bases, i));
if (PyType_IsSubtype(base, qObjType)) {
userData = retrieveTypeUserData(base);
break;
@@ -555,7 +557,9 @@ PyObject *getHiddenDataFromQObject(QObject *cppSelf, PyObject *self, PyObject *n
// Search on metaobject (avoid internal attributes started with '__')
if (!attr) {
- PyObject *type, *value, *traceback;
+ PyObject *type{};
+ PyObject *value{};
+ PyObject *traceback{};
PyErr_Fetch(&type, &value, &traceback); // This was omitted for a loong time.
int flags = currentSelectId(Py_TYPE(self));
@@ -569,16 +573,14 @@ PyObject *getHiddenDataFromQObject(QObject *cppSelf, PyObject *self, PyObject *n
// Note: before implementing this property handling, the meta function code
// below created meta functions which was quite wrong.
auto *subdict = _PepType_Lookup(Py_TYPE(self), PySideMagicName::property_methods());
- PyObject *propName = PyDict_GetItem(subdict, name);
- if (propName) {
+ if (PyObject *propName = PyDict_GetItem(subdict, name)) {
// We really have a property name and need to fetch the fget or fset function.
static PyObject *const _fget = Shiboken::String::createStaticString("fget");
static PyObject *const _fset = Shiboken::String::createStaticString("fset");
static PyObject *const _fdel = Shiboken::String::createStaticString("fdel");
static PyObject *const arr[3] = {_fget, _fset, _fdel};
- auto prop = _PepType_Lookup(Py_TYPE(self), propName);
- for (int idx = 0; idx < 3; ++idx) {
- auto *trial = arr[idx];
+ auto *prop = _PepType_Lookup(Py_TYPE(self), propName);
+ for (auto *trial : arr) {
auto *res = PyObject_GetAttr(prop, trial);
if (res) {
AutoDecRef elemName(PyObject_GetAttr(res, PySideMagicName::name()));
@@ -612,18 +614,15 @@ PyObject *getHiddenDataFromQObject(QObject *cppSelf, PyObject *self, PyObject *n
if (methMatch) {
if (method.methodType() == QMetaMethod::Signal) {
signalList.append(method);
- } else {
- PySideMetaFunction *func = MetaFunction::newObject(cppSelf, i);
- if (func) {
- PyObject *result = reinterpret_cast<PyObject *>(func);
- PyObject_SetAttr(self, name, result);
- return result;
- }
+ } else if (auto *func = MetaFunction::newObject(cppSelf, i)) {
+ auto *result = reinterpret_cast<PyObject *>(func);
+ PyObject_SetAttr(self, name, result);
+ return result;
}
}
}
if (!signalList.isEmpty()) {
- PyObject *pySignal = reinterpret_cast<PyObject *>(
+ auto *pySignal = reinterpret_cast<PyObject *>(
Signal::newObjectFromMethod(self, signalList));
PyObject_SetAttr(self, name, pySignal);
return pySignal;
@@ -701,13 +700,13 @@ static inline bool isInternalObject(const char *name)
static const QMetaObject *metaObjectCandidate(const QObject *o)
{
- auto *metaObject = o->metaObject();
+ const auto *metaObject = o->metaObject();
// Skip QML helper types and Python objects
if (hasDynamicMetaObject(o)) {
- if (auto *super = metaObject->superClass())
+ if (const auto *super = metaObject->superClass())
metaObject = super;
}
- for (auto *candidate = metaObject; candidate != nullptr; candidate = candidate->superClass()) {
+ for (const auto *candidate = metaObject; candidate != nullptr; candidate = candidate->superClass()) {
if (!isInternalObject(candidate->className())) {
metaObject = candidate;
break;
@@ -723,7 +722,7 @@ static const char *typeName(const QObject *cppSelf)
{
const char *typeName = typeid(*cppSelf).name();
if (!Shiboken::Conversions::getConverter(typeName)) {
- auto *metaObject = metaObjectCandidate(cppSelf);
+ const auto *metaObject = metaObjectCandidate(cppSelf);
for (; metaObject != nullptr; metaObject = metaObject->superClass()) {
const char *name = metaObject->className();
if (Shiboken::Conversions::getConverter(name)) {
@@ -751,7 +750,7 @@ PyTypeObject *getTypeForQObject(const QObject *cppSelf)
PyObject *getWrapperForQObject(QObject *cppSelf, PyTypeObject *sbk_type)
{
- PyObject *pyOut = reinterpret_cast<PyObject *>(Shiboken::BindingManager::instance().retrieveWrapper(cppSelf));
+ auto *pyOut = reinterpret_cast<PyObject *>(Shiboken::BindingManager::instance().retrieveWrapper(cppSelf));
if (pyOut) {
Py_INCREF(pyOut);
return pyOut;
@@ -805,7 +804,7 @@ PyObject *qStringToPyUnicode(QStringView s)
QString pyStringToQString(PyObject *str)
{
if (str == Py_None)
- return QString();
+ return {};
if (PyUnicode_Check(str) != 0)
return pyUnicodeToQString(str);
@@ -815,7 +814,7 @@ QString pyStringToQString(PyObject *str)
if (asciiBuffer)
return QString::fromLatin1(asciiBuffer);
}
- return QString();
+ return {};
}
// PySide-1499: Provide an efficient, correct PathLike interface
@@ -824,7 +823,7 @@ QString pyPathToQString(PyObject *path)
// For empty constructors path can be nullptr
// fallback to an empty QString in that case.
if (!path)
- return QString();
+ return {};
// str or bytes pass through
if (PyUnicode_Check(path) || PyBytes_Check(path))
@@ -833,7 +832,7 @@ QString pyPathToQString(PyObject *path)
// Let PyOS_FSPath do its work and then fix the result for Windows.
Shiboken::AutoDecRef strPath(PyOS_FSPath(path));
if (strPath.isNull())
- return QString();
+ return {};
return QDir::fromNativeSeparators(pyStringToQString(strPath));
}
@@ -1062,8 +1061,8 @@ static void formatPySequence(PyObject *obj, QDebug &debug)
static void formatPyDict(PyObject *obj, QDebug &debug)
{
- PyObject *key;
- PyObject *value;
+ PyObject *key{};
+ PyObject *value{};
Py_ssize_t pos = 0;
bool first = true;
debug << '{';
diff --git a/sources/pyside6/libpyside/pysideclassdecorator.cpp b/sources/pyside6/libpyside/pysideclassdecorator.cpp
index ec69c5fe7..eee49939a 100644
--- a/sources/pyside6/libpyside/pysideclassdecorator.cpp
+++ b/sources/pyside6/libpyside/pysideclassdecorator.cpp
@@ -38,7 +38,7 @@ PyObject *DecoratorPrivate::tp_call_check(PyObject *args, CheckMode checkMode) c
return nullptr;
}
- auto type = reinterpret_cast<PyTypeObject *>(arg);
+ auto *type = reinterpret_cast<PyTypeObject *>(arg);
if (checkMode != CheckMode::None && !Shiboken::ObjectType::checkType(type)) {
PyErr_Format(PyExc_TypeError,
diff --git a/sources/pyside6/libpyside/pysideclassdecorator_p.h b/sources/pyside6/libpyside/pysideclassdecorator_p.h
index 6068f6a2e..951cdd7ee 100644
--- a/sources/pyside6/libpyside/pysideclassdecorator_p.h
+++ b/sources/pyside6/libpyside/pysideclassdecorator_p.h
@@ -72,7 +72,7 @@ protected:
/// \param self self
/// \param args Arguments
/// \return 0 if the parameter is correct, else -1 (for tp_init())
- int convertToString(PyObject *self, PyObject *args);
+ static int convertToString(PyObject *self, PyObject *args);
private:
QByteArray m_string;
@@ -92,7 +92,7 @@ protected:
/// \param self self
/// \param args Arguments
/// \return 0 if the parameter is correct, else -1 (for tp_init())
- int convertToType(PyObject *self, PyObject *args);
+ static int convertToType(PyObject *self, PyObject *args);
private:
PyTypeObject *m_type = nullptr;
@@ -127,8 +127,8 @@ struct Methods
static void tp_free(void *self)
{
- auto pySelf = reinterpret_cast<PyObject *>(self);
- auto decorator = reinterpret_cast<PySideClassDecorator *>(self);
+ auto *pySelf = reinterpret_cast<PyObject *>(self);
+ auto *decorator = reinterpret_cast<PySideClassDecorator *>(self);
delete decorator->d;
PepExt_TypeCallFree(Py_TYPE(pySelf)->tp_base, self);
}
diff --git a/sources/pyside6/libpyside/pysideclassinfo.cpp b/sources/pyside6/libpyside/pysideclassinfo.cpp
index 698cb1c76..d2067e96c 100644
--- a/sources/pyside6/libpyside/pysideclassinfo.cpp
+++ b/sources/pyside6/libpyside/pysideclassinfo.cpp
@@ -54,7 +54,7 @@ PyObject *ClassInfoPrivate::tp_call(PyObject *self, PyObject *args, PyObject * /
if (pData->m_alreadyWrapped)
return PyErr_Format(PyExc_TypeError, "This instance of ClassInfo() was already used to wrap an object");
- PyTypeObject *klassType = reinterpret_cast<PyTypeObject *>(klass);
+ auto *klassType = reinterpret_cast<PyTypeObject *>(klass);
if (!PySide::ClassInfo::setClassInfo(klassType, pData->m_data))
return PyErr_Format(PyExc_TypeError, "This decorator can only be used on classes that are subclasses of QObject");
diff --git a/sources/pyside6/libpyside/pysidemetafunction.cpp b/sources/pyside6/libpyside/pysidemetafunction.cpp
index e8173b97d..10ba894a7 100644
--- a/sources/pyside6/libpyside/pysidemetafunction.cpp
+++ b/sources/pyside6/libpyside/pysidemetafunction.cpp
@@ -51,15 +51,15 @@ PyTypeObject *PySideMetaFunction_TypeF(void)
void functionFree(void *self)
{
- PySideMetaFunction *function = reinterpret_cast<PySideMetaFunction *>(self);
+ auto *function = reinterpret_cast<PySideMetaFunction *>(self);
delete function->d;
}
PyObject *functionCall(PyObject *self, PyObject *args, PyObject * /* kw */)
{
- PySideMetaFunction *function = reinterpret_cast<PySideMetaFunction *>(self);
+ auto *function = reinterpret_cast<PySideMetaFunction *>(self);
- PyObject *retVal;
+ PyObject *retVal{};
if (!PySide::MetaFunction::call(function->d->qobject, function->d->methodIndex, args, &retVal))
return nullptr;
return retVal;
@@ -123,12 +123,12 @@ bool call(QObject *self, int methodIndex, PyObject *args, PyObject **retVal)
return false;
}
- QVariant *methValues = new QVariant[numArgs];
+ auto *methValues = new QVariant[numArgs];
void **methArgs = new void *[numArgs];
// Prepare room for return type
const char *returnType = method.typeName();
- if (returnType && std::strcmp("void", returnType))
+ if (returnType && std::strcmp("void", returnType) != 0)
argTypes.prepend(returnType);
else
argTypes.prepend(QByteArray());
diff --git a/sources/pyside6/libpyside/pysideproperty.cpp b/sources/pyside6/libpyside/pysideproperty.cpp
index 3720815db..e31f4da2c 100644
--- a/sources/pyside6/libpyside/pysideproperty.cpp
+++ b/sources/pyside6/libpyside/pysideproperty.cpp
@@ -94,7 +94,7 @@ PyTypeObject *PySideProperty_TypeF(void)
PySidePropertyPrivate::PySidePropertyPrivate() noexcept = default;
PySidePropertyPrivate::~PySidePropertyPrivate() = default;
-PyObject *PySidePropertyPrivate::getValue(PyObject *source)
+PyObject *PySidePropertyPrivate::getValue(PyObject *source) const
{
if (fget) {
Shiboken::AutoDecRef args(PyTuple_New(1));
@@ -188,7 +188,7 @@ static PyObject *qpropertyTpNew(PyTypeObject *subtype, PyObject * /* args */, Py
static int qpropertyTpInit(PyObject *self, PyObject *args, PyObject *kwds)
{
PyObject *type{};
- auto data = reinterpret_cast<PySideProperty *>(self);
+ auto *data = reinterpret_cast<PySideProperty *>(self);
PySidePropertyPrivate *pData = data->d;
static const char *kwlist[] = {"type", "fget", "fset", "freset", "fdel", "doc", "notify",
@@ -298,7 +298,7 @@ _property_copy(PyObject *old, PyObject *get, PyObject *set, PyObject *reset, PyO
else
doc = pData->doc;
- auto notify = pData->notify ? pData->notify : Py_None;
+ auto *notify = pData->notify ? pData->notify : Py_None;
PyObject *obNew = PyObject_CallFunction(type, const_cast<char *>("OOOOOsO" "bbb" "bbb"),
pData->pyTypeObject, get, set, reset, del, doc.data(), notify,
@@ -338,39 +338,43 @@ static PyObject *qPropertyCall(PyObject *self, PyObject *args, PyObject * /* kw
static PyObject *qProperty_fget(PyObject *self, void *)
{
- auto func = reinterpret_cast<PySideProperty *>(self)->d->fget;
- auto ret = func != nullptr ? func : Py_None;
- Py_INCREF(ret);
- return ret;
+ auto *func = reinterpret_cast<PySideProperty *>(self)->d->fget;
+ if (func == nullptr)
+ Py_RETURN_NONE;
+ Py_INCREF(func);
+ return func;
}
static PyObject *qProperty_fset(PyObject *self, void *)
{
- auto func = reinterpret_cast<PySideProperty *>(self)->d->fset;
- auto ret = func != nullptr ? func : Py_None;
- Py_INCREF(ret);
- return ret;
+ auto *func = reinterpret_cast<PySideProperty *>(self)->d->fset;
+ if (func == nullptr)
+ Py_RETURN_NONE;
+ Py_INCREF(func);
+ return func;
}
static PyObject *qProperty_freset(PyObject *self, void *)
{
- auto func = reinterpret_cast<PySideProperty *>(self)->d->freset;
- auto ret = func != nullptr ? func : Py_None;
- Py_INCREF(ret);
- return ret;
+ auto *func = reinterpret_cast<PySideProperty *>(self)->d->freset;
+ if (func == nullptr)
+ Py_RETURN_NONE;
+ Py_INCREF(func);
+ return func;
}
static PyObject *qProperty_fdel(PyObject *self, void *)
{
- auto func = reinterpret_cast<PySideProperty *>(self)->d->fdel;
- auto ret = func != nullptr ? func : Py_None;
- Py_INCREF(ret);
- return ret;
+ auto *func = reinterpret_cast<PySideProperty *>(self)->d->fdel;
+ if (func == nullptr)
+ Py_RETURN_NONE;
+ Py_INCREF(func);
+ return func;
}
static PyObject *qPropertyDocGet(PyObject *self, void *)
{
- auto data = reinterpret_cast<PySideProperty *>(self);
+ auto *data = reinterpret_cast<PySideProperty *>(self);
PySidePropertyPrivate *pData = data->d;
QByteArray doc(pData->doc);
@@ -389,9 +393,11 @@ static PyObject *qPropertyDocGet(PyObject *self, void *)
* subclass instance instead, otherwise it gets shadowed by
* __doc__ in the class's dict.
*/
- auto get_doc_obj = get_doc.object();
- int err = PyObject_SetAttr(self, PyMagicName::doc(), get_doc);
- return err < 0 ? nullptr : (Py_INCREF(get_doc_obj), get_doc_obj);
+ auto *get_doc_obj = get_doc.object();
+ if (PyObject_SetAttr(self, PyMagicName::doc(), get_doc) < 0)
+ return nullptr;
+ Py_INCREF(get_doc_obj);
+ return get_doc_obj;
}
PyErr_Clear();
}
@@ -400,7 +406,7 @@ static PyObject *qPropertyDocGet(PyObject *self, void *)
static int qPropertyDocSet(PyObject *self, PyObject *value, void *)
{
- auto data = reinterpret_cast<PySideProperty *>(self);
+ auto *data = reinterpret_cast<PySideProperty *>(self);
PySidePropertyPrivate *pData = data->d;
if (String::check(value)) {
diff --git a/sources/pyside6/libpyside/pysideproperty_p.h b/sources/pyside6/libpyside/pysideproperty_p.h
index 10cb3ce87..7ff5c1237 100644
--- a/sources/pyside6/libpyside/pysideproperty_p.h
+++ b/sources/pyside6/libpyside/pysideproperty_p.h
@@ -26,7 +26,7 @@ public:
virtual void metaCall(PyObject *source, QMetaObject::Call call, void **args);
- PyObject *getValue(PyObject *source);
+ PyObject *getValue(PyObject *source) const;
int setValue(PyObject *source, PyObject *value);
int reset(PyObject *source);
diff --git a/sources/pyside6/libpyside/pysideqenum.cpp b/sources/pyside6/libpyside/pysideqenum.cpp
index c0479160f..897c9f4d0 100644
--- a/sources/pyside6/libpyside/pysideqenum.cpp
+++ b/sources/pyside6/libpyside/pysideqenum.cpp
@@ -75,7 +75,7 @@ static PyObject *analyzePyEnum(PyObject *pyenum)
static Py_ssize_t get_lineno()
{
- PyObject *frame = reinterpret_cast<PyObject *>(PyEval_GetFrame()); // borrowed ref
+ auto *frame = reinterpret_cast<PyObject *>(PyEval_GetFrame()); // borrowed ref
AutoDecRef ob_lineno(PyObject_GetAttr(frame, Shiboken::PyName::f_lineno()));
if (ob_lineno.isNull() || !PyLong_Check(ob_lineno))
return -1;
@@ -84,7 +84,7 @@ static Py_ssize_t get_lineno()
static bool is_module_code()
{
- PyObject *frame = reinterpret_cast<PyObject *>(PyEval_GetFrame()); // borrowed ref
+ auto *frame = reinterpret_cast<PyObject *>(PyEval_GetFrame()); // borrowed ref
AutoDecRef ob_code(PyObject_GetAttr(frame, Shiboken::PyName::f_code()));
if (ob_code.isNull())
return false;
@@ -133,14 +133,14 @@ PyObject *QEnumMacro(PyObject *pyenum, bool flag)
return nullptr;
if (bool(computedFlag) != flag) {
AutoDecRef name(PyObject_GetAttr(pyenum, PyMagicName::qualname()));
- auto cname = String::toCString(name);
+ const auto *cname = String::toCString(name);
const char *e = "Enum";
const char *f = "Flag";
PyErr_Format(PyExc_TypeError, "expected '%s' but got '%s' (%.200s)",
flag ? f : e, flag ? e : f, cname);
return nullptr;
}
- auto ok = analyzePyEnum(pyenum);
+ auto *ok = analyzePyEnum(pyenum);
if (ok == nullptr)
return nullptr;
if (is_module_code()) {
@@ -169,7 +169,7 @@ std::vector<PyObject *> resolveDelayedQEnums(PyTypeObject *containerType)
*/
if (enumCollector.empty())
return {};
- PyObject *obContainerType = reinterpret_cast<PyObject *>(containerType);
+ auto *obContainerType = reinterpret_cast<PyObject *>(containerType);
Py_ssize_t lineno = get_lineno();
std::vector<PyObject *> result;
diff --git a/sources/pyside6/libpyside/pysidesignal.cpp b/sources/pyside6/libpyside/pysidesignal.cpp
index ed0cc5d0a..07c5a3b09 100644
--- a/sources/pyside6/libpyside/pysidesignal.cpp
+++ b/sources/pyside6/libpyside/pysidesignal.cpp
@@ -26,7 +26,7 @@
#include <utility>
#include <cstring>
-#define QT_SIGNAL_SENTINEL '2'
+static constexpr char QT_SIGNAL_SENTINEL = '2';
using namespace Qt::StringLiterals;
@@ -163,7 +163,7 @@ static PyTypeObject *createMetaSignalType()
return SbkType_FromSpec(&PySideMetaSignalType_spec);
}
-static PyTypeObject *PySideMetaSignal_TypeF(void)
+static PyTypeObject *PySideMetaSignal_TypeF()
{
static auto *type = createMetaSignalType();
return type;
@@ -204,7 +204,7 @@ PyTypeObject *PySideSignal_TypeF(void)
static PyObject *signalInstanceRepr(PyObject *obSelf)
{
auto *self = reinterpret_cast<PySideSignalInstance *>(obSelf);
- auto *typeName = Py_TYPE(obSelf)->tp_name;
+ const auto *typeName = Py_TYPE(obSelf)->tp_name;
return Shiboken::String::fromFormat("<%s %s at %p>", typeName,
self->d ? self->d->signature.constData()
: "(no signature)", obSelf);
@@ -261,7 +261,7 @@ static int signalTpInit(PyObject *obSelf, PyObject *args, PyObject *kwds)
return -1;
bool tupledArgs = false;
- PySideSignal *self = reinterpret_cast<PySideSignal *>(obSelf);
+ auto *self = reinterpret_cast<PySideSignal *>(obSelf);
if (!self->data)
self->data = new PySideSignalData;
if (argName)
@@ -290,8 +290,8 @@ static int signalTpInit(PyObject *obSelf, PyObject *args, PyObject *kwds)
static void signalFree(void *vself)
{
- auto pySelf = reinterpret_cast<PyObject *>(vself);
- auto self = reinterpret_cast<PySideSignal *>(vself);
+ auto *pySelf = reinterpret_cast<PyObject *>(vself);
+ auto *self = reinterpret_cast<PySideSignal *>(vself);
if (self->data) {
delete self->data;
self->data = nullptr;
@@ -304,7 +304,7 @@ static void signalFree(void *vself)
static PyObject *signalGetItem(PyObject *obSelf, PyObject *key)
{
- auto self = reinterpret_cast<PySideSignal *>(obSelf);
+ auto *self = reinterpret_cast<PySideSignal *>(obSelf);
QByteArray sigKey;
if (key) {
sigKey = PySide::Signal::parseSignature(key).signature;
@@ -318,7 +318,7 @@ static PyObject *signalGetItem(PyObject *obSelf, PyObject *key)
static PyObject *signalToString(PyObject *obSelf)
{
- auto self = reinterpret_cast<PySideSignal *>(obSelf);
+ auto *self = reinterpret_cast<PySideSignal *>(obSelf);
QByteArray result;
if (self->data == nullptr || self->data->signatures.isEmpty()) {
result = "<invalid>"_ba;
@@ -335,7 +335,7 @@ static PyObject *signalToString(PyObject *obSelf)
static PyObject *signalGetAttr(PyObject *obSelf, PyObject *name)
{
- auto self = reinterpret_cast<PySideSignal *>(obSelf);
+ auto *self = reinterpret_cast<PySideSignal *>(obSelf);
if (PyUnicode_CompareWithASCIIString(name, "signatures") != 0)
return PyObject_GenericGetAttr(obSelf, name);
@@ -354,8 +354,8 @@ static PyObject *signalGetAttr(PyObject *obSelf, PyObject *name)
static void signalInstanceFree(void *vself)
{
- auto pySelf = reinterpret_cast<PyObject *>(vself);
- auto self = reinterpret_cast<PySideSignalInstance *>(vself);
+ auto *pySelf = reinterpret_cast<PyObject *>(vself);
+ auto *self = reinterpret_cast<PySideSignalInstance *>(vself);
PySideSignalInstancePrivate *dataPvt = self->d;
if (dataPvt) {
@@ -483,7 +483,7 @@ static PyObject *signalInstanceConnect(PyObject *self, PyObject *args, PyObject
"O|O:SignalInstance", const_cast<char **>(kwlist), &slot, &type))
return nullptr;
- PySideSignalInstance *source = reinterpret_cast<PySideSignalInstance *>(self);
+ auto *source = reinterpret_cast<PySideSignalInstance *>(self);
if (!source->d)
return PyErr_Format(PyExc_RuntimeError, "cannot connect uninitialized SignalInstance");
if (source->deleted)
@@ -497,7 +497,7 @@ static PyObject *signalInstanceConnect(PyObject *self, PyObject *args, PyObject
//find best match
while (sourceWalk && !match) {
- auto targetWalk = reinterpret_cast<PySideSignalInstance *>(slot);
+ auto *targetWalk = reinterpret_cast<PySideSignalInstance *>(slot);
while (targetWalk && !match) {
if (QMetaObject::checkConnectArgs(sourceWalk->d->signature,
targetWalk->d->signature)) {
@@ -575,12 +575,12 @@ static PyObject *signalInstanceConnect(PyObject *self, PyObject *args, PyObject
static int argCountInSignature(const char *signature)
{
- return QByteArray(signature).count(",") + 1;
+ return QByteArrayView{signature}.count(',') + 1;
}
static PyObject *signalInstanceEmit(PyObject *self, PyObject *args)
{
- PySideSignalInstance *source = reinterpret_cast<PySideSignalInstance *>(self);
+ auto *source = reinterpret_cast<PySideSignalInstance *>(self);
if (!source->d)
return PyErr_Format(PyExc_RuntimeError, "cannot emit uninitialized SignalInstance");
@@ -632,7 +632,7 @@ static PyObject *signalInstanceGetItem(PyObject *self, PyObject *key)
const auto sig = PySide::Signal::buildSignature(sigName, sigKey);
for (auto *data = firstSignal; data != nullptr; data = data->d->next) {
if (data->d->signature == sig) {
- PyObject *result = reinterpret_cast<PyObject *>(data);
+ auto *result = reinterpret_cast<PyObject *>(data);
Py_INCREF(result);
return result;
}
@@ -653,7 +653,9 @@ static PyObject *signalInstanceGetItem(PyObject *self, PyObject *key)
static inline void warnDisconnectFailed(PyObject *aSlot, const QByteArray &signature)
{
if (PyErr_Occurred() != nullptr) { // avoid "%S" invoking str() when an error is set.
- PyObject *exc{}, *inst{}, *tb{};
+ PyObject *exc{};
+ PyObject *inst{};
+ PyObject *tb{};
PyErr_Fetch(&exc, &inst, &tb);
PyErr_WarnFormat(PyExc_RuntimeWarning, 0, "Failed to disconnect (%s) from signal \"%s\".",
Py_TYPE(aSlot)->tp_name, signature.constData());
@@ -666,7 +668,7 @@ static inline void warnDisconnectFailed(PyObject *aSlot, const QByteArray &signa
static PyObject *signalInstanceDisconnect(PyObject *self, PyObject *args)
{
- auto source = reinterpret_cast<PySideSignalInstance *>(self);
+ auto *source = reinterpret_cast<PySideSignalInstance *>(self);
if (!source->d)
return PyErr_Format(PyExc_RuntimeError, "cannot disconnect uninitialized SignalInstance");
@@ -678,7 +680,7 @@ static PyObject *signalInstanceDisconnect(PyObject *self, PyObject *args)
bool match = false;
if (Py_TYPE(slot) == PySideSignalInstance_TypeF()) {
- PySideSignalInstance *target = reinterpret_cast<PySideSignalInstance *>(slot);
+ auto *target = reinterpret_cast<PySideSignalInstance *>(slot);
if (QMetaObject::checkConnectArgs(source->d->signature, target->d->signature)) {
PyList_Append(pyArgs, source->d->source);
Shiboken::AutoDecRef source_signature(PySide::Signal::buildQtCompatible(source->d->signature));
@@ -722,7 +724,7 @@ static PyObject *signalInstanceDisconnect(PyObject *self, PyObject *args)
// PYSIDE-68: Supply the missing __get__ function
static PyObject *signalDescrGet(PyObject *self, PyObject *obj, PyObject * /*type*/)
{
- auto signal = reinterpret_cast<PySideSignal *>(self);
+ auto *signal = reinterpret_cast<PySideSignal *>(self);
// Return the unbound signal if there is nothing to bind it to.
if (obj == nullptr || obj == Py_None
|| !PySide::isQObjectDerived(Py_TYPE(obj), true)) {
@@ -745,7 +747,7 @@ static PyObject *signalDescrGet(PyObject *self, PyObject *obj, PyObject * /*type
static PyObject *signalCall(PyObject *self, PyObject *args, PyObject *kw)
{
- auto signal = reinterpret_cast<PySideSignal *>(self);
+ auto *signal = reinterpret_cast<PySideSignal *>(self);
// Native C++ signals can't be called like functions, thus we throw an exception.
// The only way calling a signal can succeed (the Python equivalent of C++'s operator() )
@@ -803,9 +805,10 @@ static PyObject *_getHomonymousMethod(PySideSignalInstance *inst)
auto *sub_type = reinterpret_cast<PyTypeObject *>(PyTuple_GET_ITEM(mro, idx));
Shiboken::AutoDecRef tpDict(PepType_GetDict(sub_type));
auto *hom = PyDict_GetItem(tpDict, name);
- PyObject *realFunc{};
- if (hom && PyCallable_Check(hom) && (realFunc = _getRealCallable(hom)))
- return realFunc;
+ if (hom != nullptr && PyCallable_Check(hom) != 0) {
+ if (auto *realFunc = _getRealCallable(hom))
+ return realFunc;
+ }
}
return nullptr;
}
@@ -908,8 +911,9 @@ void updateSourceObject(PyObject *source)
// PYSIDE-1431: Walk the mro and update. But see PYSIDE-1751 below.
while ((mroItem.reset(PyIter_Next(mroIterator))), mroItem.object()) {
+ PyObject *key{};
+ PyObject *value{};
Py_ssize_t pos = 0;
- PyObject *key, *value;
auto *type = reinterpret_cast<PyTypeObject *>(mroItem.object());
Shiboken::AutoDecRef tpDict(PepType_GetDict(type));
while (PyDict_Next(tpDict, &pos, &key, &value)) {
@@ -963,7 +967,7 @@ QByteArray getTypeName(PyObject *obType)
result = sizeof(qreal) == sizeof(double) ? "double" : "float";
return result;
}
- return QByteArray();
+ return {};
}
static QByteArray buildSignature(const QByteArray &name, const QByteArray &signature)
@@ -1045,7 +1049,7 @@ PySideSignalInstance *initialize(PySideSignal *self, PyObject *name, PyObject *o
PySideSignalInstance *instance = PyObject_New(PySideSignalInstance,
PySideSignalInstance_TypeF());
instanceInitialize(instance, name, self, object, 0);
- auto sbkObj = reinterpret_cast<SbkObject *>(object);
+ auto *sbkObj = reinterpret_cast<SbkObject *>(object);
if (!Shiboken::Object::wasCreatedByPython(sbkObj))
Py_INCREF(object); // PYSIDE-79: this flag was crucial for a wrapper call.
return instance;
@@ -1090,7 +1094,7 @@ PySideSignalInstance *newObjectFromMethod(PyObject *source, const QList<QMetaMet
// separate SignalName
selfPvt->signalName = cppName;
selfPvt->signature = m.methodSignature();
- selfPvt->argCount = int(m.parameterCount());
+ selfPvt->argCount = short(m.parameterCount());
selfPvt->attributes = m.attributes();
selfPvt->homonymousMethod = nullptr;
selfPvt->next = nullptr;
@@ -1101,9 +1105,8 @@ PySideSignalInstance *newObjectFromMethod(PyObject *source, const QList<QMetaMet
static void _addSignalToWrapper(PyTypeObject *wrapperType, const char *signalName, PySideSignal *signal)
{
Shiboken::AutoDecRef tpDict(PepType_GetDict(wrapperType));
- auto typeDict = tpDict.object();
- PyObject *homonymousMethod;
- if ((homonymousMethod = PyDict_GetItemString(typeDict, signalName))) {
+ auto *typeDict = tpDict.object();
+ if (auto *homonymousMethod = PyDict_GetItemString(typeDict, signalName)) {
Py_INCREF(homonymousMethod);
signal->homonymousMethod = homonymousMethod;
}
@@ -1184,7 +1187,7 @@ EmitterData getEmitterData(PySideSignalInstance *signal)
EmitterData result;
result.emitter = PySide::convertToQObject(getObject(signal), false);
if (result.emitter != nullptr) {
- auto *mo = result.emitter->metaObject();
+ const auto *mo = result.emitter->metaObject();
result.methodIndex = mo->indexOfMethod(getSignature(signal));
}
return result;
@@ -1244,7 +1247,7 @@ QByteArray getCallbackSignature(const char *signal, QObject *receiver,
}
#endif
} else if (PyCFunction_Check(callback)) {
- const PyCFunctionObject *funcObj = reinterpret_cast<const PyCFunctionObject *>(callback);
+ const auto *funcObj = reinterpret_cast<const PyCFunctionObject *>(callback);
functionName = PepCFunction_GET_NAMESTR(funcObj);
useSelf = PyCFunction_GET_SELF(funcObj) != nullptr ? 1 : 0;
const int flags = PyCFunction_GET_FLAGS(funcObj);
diff --git a/sources/pyside6/libpyside/pysideslot.cpp b/sources/pyside6/libpyside/pysideslot.cpp
index fa7e89f42..23e8068d6 100644
--- a/sources/pyside6/libpyside/pysideslot.cpp
+++ b/sources/pyside6/libpyside/pysideslot.cpp
@@ -84,7 +84,7 @@ int slotTpInit(PyObject *self, PyObject *args, PyObject *kw)
return -1;
}
- PySideSlot *data = reinterpret_cast<PySideSlot *>(self);
+ auto *data = reinterpret_cast<PySideSlot *>(self);
if (!data->slotData)
data->slotData = new SlotData;
for(Py_ssize_t i = 0, i_max = PyTuple_Size(args); i < i_max; i++) {
@@ -120,7 +120,7 @@ PyObject *slotCall(PyObject *self, PyObject *args, PyObject * /* kw */)
Py_INCREF(callback);
if (PyCallable_Check(callback)) {
- PySideSlot *data = reinterpret_cast<PySideSlot *>(self);
+ auto *data = reinterpret_cast<PySideSlot *>(self);
if (!data->slotData)
data->slotData = new SlotData;
diff --git a/sources/pyside6/libpyside/pysideweakref.cpp b/sources/pyside6/libpyside/pysideweakref.cpp
index 5f3ca59e4..e4d6a9a3d 100644
--- a/sources/pyside6/libpyside/pysideweakref.cpp
+++ b/sources/pyside6/libpyside/pysideweakref.cpp
@@ -42,7 +42,7 @@ static PyTypeObject *PySideCallableObject_TypeF()
static PyObject *CallableObject_call(PyObject *callable_object, PyObject *args, PyObject * /* kw */)
{
- PySideCallableObject *obj = reinterpret_cast<PySideCallableObject *>(callable_object);
+ auto *obj = reinterpret_cast<PySideCallableObject *>(callable_object);
obj->weakref_func(obj->user_data);
Py_XDECREF(PyTuple_GET_ITEM(args, 0)); //kill weak ref object
diff --git a/sources/pyside6/libpyside/qobjectconnect.cpp b/sources/pyside6/libpyside/qobjectconnect.cpp
index 3c5b75953..1d9453ab1 100644
--- a/sources/pyside6/libpyside/qobjectconnect.cpp
+++ b/sources/pyside6/libpyside/qobjectconnect.cpp
@@ -8,7 +8,8 @@
#include "pysideutils.h"
#include "signalmanager.h"
-#include "shiboken.h"
+#include <sbkstring.h>
+#include <sbkstaticstrings.h>
#include "basewrapper.h"
#include "autodecref.h"
@@ -29,7 +30,7 @@ static bool isMethodDecorator(PyObject *method, bool is_pymethod, PyObject *self
// PYSIDE-1523: Each could be a compiled method or a normal method here, for the
// compiled ones we can use the attributes.
- PyObject *function1;
+ PyObject *function1{};
if (PyMethod_Check(otherMethod.object())) {
function1 = PyMethod_GET_FUNCTION(otherMethod.object());
} else {
@@ -40,7 +41,7 @@ static bool isMethodDecorator(PyObject *method, bool is_pymethod, PyObject *self
// Not retaining a reference in line with what PyMethod_GET_FUNCTION does.
}
- PyObject *function2;
+ PyObject *function2{};
if (is_pymethod) {
function2 = PyMethod_GET_FUNCTION(method);
} else {
@@ -85,7 +86,7 @@ static const char *getQualifiedName(PyObject *ob)
static bool isDeclaredIn(PyObject *method, const char *className)
{
bool result = false;
- if (auto *qualifiedNameC = getQualifiedName(PyMethod_Function(method))) {
+ if (const auto *qualifiedNameC = getQualifiedName(PyMethod_Function(method))) {
std::string_view qualifiedName(qualifiedNameC);
if (const auto dot = qualifiedName.rfind('.'); dot != std::string::npos)
result = qualifiedName.substr(0, dot) == className;
@@ -147,7 +148,7 @@ static GetReceiverResult getReceiver(QObject *source, const char *signal,
}
}
- const auto receiverThread = result.receiver ? result.receiver->thread() : nullptr;
+ auto *receiverThread = result.receiver ? result.receiver->thread() : nullptr;
if (result.usingGlobalReceiver) {
PySide::SignalManager &signalManager = PySide::SignalManager::instance();
@@ -281,7 +282,7 @@ QMetaObject::Connection qobjectConnectCallback(QObject *source, const char *sign
PySide::SignalManager &signalManager = PySide::SignalManager::instance();
- PySideQSlotObject *slotObject = new PySideQSlotObject(callback);
+ auto *slotObject = new PySideQSlotObject(callback);
QMetaObject::Connection connection{};
Py_BEGIN_ALLOW_THREADS // PYSIDE-2367, prevent threading deadlocks with connectNotify()
diff --git a/sources/pyside6/libpyside/signalmanager.cpp b/sources/pyside6/libpyside/signalmanager.cpp
index f4c2bbf43..5b17be510 100644
--- a/sources/pyside6/libpyside/signalmanager.cpp
+++ b/sources/pyside6/libpyside/signalmanager.cpp
@@ -37,8 +37,7 @@ using namespace Qt::StringLiterals;
#if QSLOT_CODE != 1 || QSIGNAL_CODE != 2
#error QSLOT_CODE and/or QSIGNAL_CODE changed! change the hardcoded stuff to the correct value!
#endif
-#define PYSIDE_SLOT '1'
-#define PYSIDE_SIGNAL '2'
+
#include "globalreceiverv2.h"
static PyObject *metaObjectAttr = nullptr;
@@ -49,7 +48,7 @@ static bool qAppRunning = false;
static void destroyMetaObject(PyObject *obj)
{
void *ptr = PyCapsule_GetPointer(obj, nullptr);
- auto meta = reinterpret_cast<PySide::MetaObjectBuilder *>(ptr);
+ auto *meta = reinterpret_cast<PySide::MetaObjectBuilder *>(ptr);
SbkObject *wrapper = Shiboken::BindingManager::instance().retrieveWrapper(meta);
if (wrapper)
Shiboken::BindingManager::instance().releaseWrapper(wrapper);
@@ -77,7 +76,7 @@ static const char *metaCallName(QMetaObject::Call call)
static QByteArray methodSignature(const QMetaMethod &method)
{
QByteArray result;
- if (auto *t = method.typeName()) {
+ if (const auto *t = method.typeName()) {
result += t;
result += ' ';
}
@@ -236,6 +235,7 @@ public:
Q_DISABLE_COPY_MOVE(SignalManagerDestroyListener)
using QObject::QObject;
+ ~SignalManagerDestroyListener() override = default;
public Q_SLOTS:
void destroyNotify(const QObject *);
@@ -301,7 +301,7 @@ static PythonToCppFunc is_PyObject_PythonToCpp_PyObject_PTR_Convertible(PyObject
}
static PyObject *PyObject_PTR_CppToPython_PyObject(const void *cppIn)
{
- auto pyOut = reinterpret_cast<PyObject *>(const_cast<void *>(cppIn));
+ auto *pyOut = reinterpret_cast<PyObject *>(const_cast<void *>(cppIn));
if (pyOut)
Py_INCREF(pyOut);
return pyOut;
@@ -413,7 +413,7 @@ void SignalManager::notifyGlobalReceiver(QObject *receiver)
void SignalManager::releaseGlobalReceiver(const QObject *source, QObject *receiver)
{
- auto gr = static_cast<GlobalReceiverV2 *>(receiver);
+ auto *gr = static_cast<GlobalReceiverV2 *>(receiver);
gr->decRef(source);
if (gr->isEmpty())
m_d->deleteGlobalReceiver(gr);
@@ -461,7 +461,7 @@ void SignalManager::SignalManagerPrivate::purgeEmptyGlobalReceivers()
}
}
-int SignalManager::globalReceiverSlotIndex(QObject *receiver, const char *signature) const
+int SignalManager::globalReceiverSlotIndex(QObject *receiver, const char *signature)
{
return static_cast<GlobalReceiverV2 *>(receiver)->addSlot(signature);
}
@@ -528,7 +528,9 @@ int SignalManager::SignalManagerPrivate::qtPropertyMetacall(QObject *object,
if (PyErr_Occurred()) {
// PYSIDE-2160: An unknown type was reported. Indicated by StopIteration.
if (PyErr_ExceptionMatches(PyExc_StopIteration)) {
- PyObject *excType, *excValue, *excTraceback;
+ PyObject *excType{};
+ PyObject *excValue{};
+ PyObject *excTraceback{};
PyErr_Fetch(&excType, &excValue, &excTraceback);
bool ign = call == QMetaObject::WriteProperty;
PyErr_WarnFormat(PyExc_RuntimeWarning, 0,
@@ -585,7 +587,7 @@ int SignalManager::SignalManagerPrivate::qtMethodMetacall(QObject *object,
// WARNING Isn't safe to call any metaObject and/or object methods beyond this point
// because the object can be deleted inside the called slot.
- if (gil.get() == nullptr)
+ if (gil == nullptr)
gil.reset(new Shiboken::GilState);
if (PyErr_Occurred())
diff --git a/sources/pyside6/libpyside/signalmanager.h b/sources/pyside6/libpyside/signalmanager.h
index 397700df1..3fdf3e9b5 100644
--- a/sources/pyside6/libpyside/signalmanager.h
+++ b/sources/pyside6/libpyside/signalmanager.h
@@ -63,10 +63,10 @@ public:
QObject* globalReceiver(QObject *sender, PyObject *callback, QObject *receiver = nullptr);
void releaseGlobalReceiver(const QObject* sender, QObject* receiver);
- int globalReceiverSlotIndex(QObject* sender, const char* slotSignature) const;
+ static int globalReceiverSlotIndex(QObject* sender, const char* slotSignature);
void notifyGlobalReceiver(QObject* receiver);
- bool emitSignal(QObject* source, const char* signal, PyObject* args);
+ static bool emitSignal(QObject* source, const char* signal, PyObject* args);
static int qt_metacall(QObject* object, QMetaObject::Call call, int id, void** args);
// Used to register a new signal/slot on QMetaobject of source.