aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sources/pyside6/PySide6/QtQml/pysideqmlregistertype.cpp20
-rw-r--r--sources/pyside6/libpyside/globalreceiverv2.cpp16
-rw-r--r--sources/pyside6/libpyside/pyside.cpp10
-rw-r--r--sources/pyside6/libpyside/pysideclassinfo.cpp20
-rw-r--r--sources/pyside6/libpyside/pysidemetafunction.cpp30
-rw-r--r--sources/pyside6/libpyside/pysideproperty.cpp40
-rw-r--r--sources/pyside6/libpyside/pysideqflags.cpp29
-rw-r--r--sources/pyside6/libpyside/pysidesignal.cpp76
-rw-r--r--sources/pyside6/libpyside/pysideslot.cpp20
-rw-r--r--sources/pyside6/libpyside/pysideweakref.cpp15
-rw-r--r--sources/pyside6/libpyside/signalmanager.cpp43
-rw-r--r--sources/pyside6/tests/pysidetest/testobject.h12
-rw-r--r--sources/pyside6/tests/pysidetest/testview.cpp4
-rw-r--r--sources/shiboken6/tests/libsample/objecttype.cpp2
14 files changed, 165 insertions, 172 deletions
diff --git a/sources/pyside6/PySide6/QtQml/pysideqmlregistertype.cpp b/sources/pyside6/PySide6/QtQml/pysideqmlregistertype.cpp
index 29fd8be77..6bcc1dccc 100644
--- a/sources/pyside6/PySide6/QtQml/pysideqmlregistertype.cpp
+++ b/sources/pyside6/PySide6/QtQml/pysideqmlregistertype.cpp
@@ -340,10 +340,10 @@ void propListTpFree(void *self)
}
static PyType_Slot PropertyListType_slots[] = {
- {Py_tp_init, (void *)propListTpInit},
- {Py_tp_free, (void *)propListTpFree},
- {Py_tp_dealloc, (void *)Sbk_object_dealloc},
- {0, 0}
+ {Py_tp_init, reinterpret_cast<void *>(propListTpInit)},
+ {Py_tp_free, reinterpret_cast<void *>(propListTpFree)},
+ {Py_tp_dealloc, reinterpret_cast<void *>(Sbk_object_dealloc)},
+ {0, nullptr}
};
static PyType_Spec PropertyListType_spec = {
"2:PySide6.QtQml.ListProperty",
@@ -558,7 +558,7 @@ static PyMethodDef QtQml_VolatileBoolObject_methods[] = {
{"set", reinterpret_cast<PyCFunction>(QtQml_VolatileBoolObject_set), METH_VARARGS,
"B.set(a) -> None. Sets the value of the volatile boolean"
},
- {Q_NULLPTR} /* Sentinel */
+ {nullptr, nullptr, 0, nullptr} /* Sentinel */
};
static PyObject *
@@ -592,11 +592,11 @@ QtQml_VolatileBoolObject_str(QtQml_VolatileBoolObject *self)
}
static PyType_Slot QtQml_VolatileBoolType_slots[] = {
- {Py_tp_repr, (void *)reinterpret_cast<reprfunc>(QtQml_VolatileBoolObject_repr)},
- {Py_tp_str, (void *)reinterpret_cast<reprfunc>(QtQml_VolatileBoolObject_str)},
- {Py_tp_methods, (void *)QtQml_VolatileBoolObject_methods},
- {Py_tp_new, (void *)QtQml_VolatileBoolObject_new},
- {Py_tp_dealloc, (void *)QtQml_VolatileBoolObject_dealloc},
+ {Py_tp_repr, reinterpret_cast<void *>(QtQml_VolatileBoolObject_repr)},
+ {Py_tp_str, reinterpret_cast<void *>(QtQml_VolatileBoolObject_str)},
+ {Py_tp_methods, reinterpret_cast<void *>(QtQml_VolatileBoolObject_methods)},
+ {Py_tp_new, reinterpret_cast<void *>(QtQml_VolatileBoolObject_new)},
+ {Py_tp_dealloc, reinterpret_cast<void *>(QtQml_VolatileBoolObject_dealloc)},
{0, 0}
};
static PyType_Spec QtQml_VolatileBoolType_spec = {
diff --git a/sources/pyside6/libpyside/globalreceiverv2.cpp b/sources/pyside6/libpyside/globalreceiverv2.cpp
index 8ff5d896f..1bbafb4ec 100644
--- a/sources/pyside6/libpyside/globalreceiverv2.cpp
+++ b/sources/pyside6/libpyside/globalreceiverv2.cpp
@@ -49,6 +49,8 @@
#include <QtCore/QMetaMethod>
#include <QtCore/QSet>
+#include <cstring>
+
#define RECEIVER_DESTROYED_SLOT_NAME "__receiverDestroyed__(QObject*)"
namespace
@@ -159,7 +161,7 @@ int DynamicSlotDataV2::addSlot(const char *signature)
void DynamicSlotDataV2::onCallbackDestroyed(void *data)
{
auto self = reinterpret_cast<DynamicSlotDataV2 *>(data);
- self->m_weakRef = 0;
+ self->m_weakRef = nullptr;
Py_BEGIN_ALLOW_THREADS
delete self->m_parent;
Py_END_ALLOW_THREADS
@@ -170,7 +172,7 @@ DynamicSlotDataV2::~DynamicSlotDataV2()
Shiboken::GilState gil;
Py_XDECREF(m_weakRef);
- m_weakRef = 0;
+ m_weakRef = nullptr;
if (!m_isMethod)
Py_DECREF(m_callback);
@@ -184,7 +186,7 @@ GlobalReceiverV2::GlobalReceiverV2(PyObject *callback, GlobalReceiverV2MapPtr ma
m_data = new DynamicSlotDataV2(callback, this);
m_metaObject.addSlot(RECEIVER_DESTROYED_SLOT_NAME);
m_metaObject.update();
- m_refs.append(NULL);
+ m_refs.append(nullptr);
if (DESTROY_SIGNAL_ID == 0)
@@ -222,7 +224,7 @@ void GlobalReceiverV2::incRef(const QObject *link)
{
if (link) {
if (!m_refs.contains(link)) {
- bool connected;
+ bool connected{};
Py_BEGIN_ALLOW_THREADS
connected = QMetaObject::connect(link, DESTROY_SIGNAL_ID, this, DESTROY_SLOT_ID);
Py_END_ALLOW_THREADS
@@ -234,7 +236,7 @@ void GlobalReceiverV2::incRef(const QObject *link)
m_refs.append(link);
}
} else {
- m_refs.append(NULL);
+ m_refs.append(nullptr);
}
}
@@ -247,7 +249,7 @@ void GlobalReceiverV2::decRef(const QObject *link)
m_refs.removeOne(link);
if (link) {
if (!m_refs.contains(link)) {
- bool result;
+ bool result{};
Py_BEGIN_ALLOW_THREADS
result = QMetaObject::disconnect(link, DESTROY_SIGNAL_ID, this, DESTROY_SLOT_ID);
Py_END_ALLOW_THREADS
@@ -324,7 +326,7 @@ int GlobalReceiverV2::qt_metacall(QMetaObject::Call call, int id, void **args)
m_refs.removeAll(obj); // remove all refs to this object
decRef(); //remove the safe ref
} else {
- bool isShortCuit = (strstr(slot.methodSignature(), "(") == 0);
+ const bool isShortCuit = std::strchr(slot.methodSignature(), '(') == nullptr;
Shiboken::AutoDecRef callback(m_data->callback());
SignalManager::callPythonMetaMethod(slot, args, callback, isShortCuit);
}
diff --git a/sources/pyside6/libpyside/pyside.cpp b/sources/pyside6/libpyside/pyside.cpp
index 22230703e..80f0e1b7e 100644
--- a/sources/pyside6/libpyside/pyside.cpp
+++ b/sources/pyside6/libpyside/pyside.cpp
@@ -85,7 +85,7 @@ namespace PySide
void init(PyObject *module)
{
- qobjectNextAddr = 0;
+ qobjectNextAddr = nullptr;
ClassInfo::init(module);
Signal::init(module);
Slot::init(module);
@@ -323,7 +323,7 @@ PyObject *getMetaDataFromQObject(QObject *cppSelf, PyObject *self, PyObject *nam
PyObject *value = Property::getValue(reinterpret_cast<PySideProperty *>(attr), self);
Py_DECREF(attr);
if (!value)
- return 0;
+ return nullptr;
attr = value;
}
@@ -376,7 +376,7 @@ bool inherits(PyTypeObject *objType, const char *class_name)
return true;
PyTypeObject *base = objType->tp_base;
- if (base == 0)
+ if (base == nullptr)
return false;
return inherits(base, class_name);
@@ -408,7 +408,7 @@ static void invalidatePtr(any_t *object)
Shiboken::GilState state;
SbkObject *wrapper = Shiboken::BindingManager::instance().retrieveWrapper(object);
- if (wrapper != NULL)
+ if (wrapper != nullptr)
Shiboken::BindingManager::instance().releaseWrapper(wrapper);
}
@@ -548,7 +548,7 @@ bool registerInternalQtConf()
// because tests are executed before the package is installed, and thus the Prefix specified
// in qt.conf would point to a not yet existing location.
bool disableInternalQtConf =
- qEnvironmentVariableIntValue("PYSIDE_DISABLE_INTERNAL_QT_CONF") > 0 ? true : false;
+ qEnvironmentVariableIntValue("PYSIDE_DISABLE_INTERNAL_QT_CONF") > 0;
if (disableInternalQtConf || executableQtConfAvailable) {
registrationAttempted = true;
return false;
diff --git a/sources/pyside6/libpyside/pysideclassinfo.cpp b/sources/pyside6/libpyside/pysideclassinfo.cpp
index 2a9914a68..6bd5a7650 100644
--- a/sources/pyside6/libpyside/pysideclassinfo.cpp
+++ b/sources/pyside6/libpyside/pysideclassinfo.cpp
@@ -56,12 +56,12 @@ static void classInfoFree(void *);
static PyObject *classCall(PyObject *, PyObject *, PyObject *);
static PyType_Slot PySideClassInfoType_slots[] = {
- {Py_tp_call, (void *)classCall},
- {Py_tp_init, (void *)classInfoTpInit},
- {Py_tp_new, (void *)classInfoTpNew},
- {Py_tp_free, (void *)classInfoFree},
- {Py_tp_dealloc, (void *)Sbk_object_dealloc},
- {0, 0}
+ {Py_tp_call, reinterpret_cast<void *>(classCall)},
+ {Py_tp_init, reinterpret_cast<void *>(classInfoTpInit)},
+ {Py_tp_new, reinterpret_cast<void *>(classInfoTpNew)},
+ {Py_tp_free, reinterpret_cast<void *>(classInfoFree)},
+ {Py_tp_dealloc, reinterpret_cast<void *>(Sbk_object_dealloc)},
+ {0, nullptr}
};
static PyType_Spec PySideClassInfoType_spec = {
"2:PySide6.QtCore.ClassInfo",
@@ -85,7 +85,7 @@ PyObject *classCall(PyObject *self, PyObject *args, PyObject * /* kw */)
PyErr_Format(PyExc_TypeError,
"The ClassInfo decorator takes exactly 1 positional argument (%zd given)",
PyTuple_Size(args));
- return 0;
+ return nullptr;
}
PySideClassInfo *data = reinterpret_cast<PySideClassInfo *>(self);
@@ -93,7 +93,7 @@ PyObject *classCall(PyObject *self, PyObject *args, PyObject * /* kw */)
if (pData->m_alreadyWrapped) {
PyErr_SetString(PyExc_TypeError, "This instance of ClassInfo() was already used to wrap an object");
- return 0;
+ return nullptr;
}
PyObject *klass = PyTuple_GetItem(args, 0);
@@ -102,7 +102,7 @@ PyObject *classCall(PyObject *self, PyObject *args, PyObject * /* kw */)
// This will sometimes segfault if you mistakenly use it on a function declaration
if (!PyType_Check(klass)) {
PyErr_SetString(PyExc_TypeError, "This decorator can only be used on class declarations");
- return 0;
+ return nullptr;
}
PyTypeObject *klassType = reinterpret_cast<PyTypeObject *>(klass);
@@ -117,7 +117,7 @@ PyObject *classCall(PyObject *self, PyObject *args, PyObject * /* kw */)
if (!validClass) {
PyErr_SetString(PyExc_TypeError, "This decorator can only be used on classes that are subclasses of QObject");
- return 0;
+ return nullptr;
}
Py_INCREF(klass);
diff --git a/sources/pyside6/libpyside/pysidemetafunction.cpp b/sources/pyside6/libpyside/pysidemetafunction.cpp
index 939e52e12..e66732d78 100644
--- a/sources/pyside6/libpyside/pysidemetafunction.cpp
+++ b/sources/pyside6/libpyside/pysidemetafunction.cpp
@@ -59,11 +59,11 @@ static void functionFree(void *);
static PyObject *functionCall(PyObject *, PyObject *, PyObject *);
static PyType_Slot PySideMetaFunctionType_slots[] = {
- {Py_tp_call, (void *)functionCall},
- {Py_tp_new, (void *)PyType_GenericNew},
- {Py_tp_free, (void *)functionFree},
- {Py_tp_dealloc, (void *)Sbk_object_dealloc},
- {0, 0}
+ {Py_tp_call, reinterpret_cast<void *>(functionCall)},
+ {Py_tp_new, reinterpret_cast<void *>(PyType_GenericNew)},
+ {Py_tp_free, reinterpret_cast<void *>(functionFree)},
+ {Py_tp_dealloc, reinterpret_cast<void *>(Sbk_object_dealloc)},
+ {0, nullptr}
};
static PyType_Spec PySideMetaFunctionType_spec = {
"2:PySide6.QtCore.MetaFunction",
@@ -93,13 +93,13 @@ PyObject *functionCall(PyObject *self, PyObject *args, PyObject * /* kw */)
PyObject *retVal;
if (!PySide::MetaFunction::call(function->d->qobject, function->d->methodIndex, args, &retVal))
- return 0;
+ return nullptr;
return retVal;
}
} // extern "C"
-namespace PySide { namespace MetaFunction {
+namespace PySide::MetaFunction {
static const char *MetaFunction_SignatureStrings[] = {
"PySide6.QtCore.MetaFunction.__call__(self,*args:typing.Any)->typing.Any",
@@ -117,7 +117,7 @@ void init(PyObject *module)
PySideMetaFunction *newObject(QObject *source, int methodIndex)
{
if (methodIndex >= source->metaObject()->methodCount())
- return 0;
+ return nullptr;
QMetaMethod method = source->metaObject()->method(methodIndex);
if ((method.methodType() == QMetaMethod::Slot) ||
@@ -128,7 +128,7 @@ PySideMetaFunction *newObject(QObject *source, int methodIndex)
function->d->methodIndex = methodIndex;
return function;
}
- return 0;
+ return nullptr;
}
bool call(QObject *self, int methodIndex, PyObject *args, PyObject **retVal)
@@ -138,7 +138,7 @@ bool call(QObject *self, int methodIndex, PyObject *args, PyObject **retVal)
QList<QByteArray> argTypes = method.parameterTypes();
// args given plus return type
- Shiboken::AutoDecRef sequence(PySequence_Fast(args, 0));
+ Shiboken::AutoDecRef sequence(PySequence_Fast(args, nullptr));
int numArgs = PySequence_Fast_GET_SIZE(sequence.object()) + 1;
if (numArgs - 1 > argTypes.count()) {
@@ -165,12 +165,12 @@ bool call(QObject *self, int methodIndex, PyObject *args, PyObject **retVal)
else
argTypes.prepend(QByteArray());
- int i;
- for (i = 0; i < numArgs; ++i) {
+ int i = 0;
+ for (; i < numArgs; ++i) {
const QByteArray &typeName = argTypes.at(i);
// This must happen only when the method hasn't return type.
if (typeName.isEmpty()) {
- methArgs[i] = 0;
+ methArgs[i] = nullptr;
continue;
}
@@ -225,7 +225,5 @@ bool call(QObject *self, int methodIndex, PyObject *args, PyObject **retVal)
return ok;
}
-
-} //namespace MetaFunction
-} //namespace PySide
+} //namespace PySide::MetaFunction
diff --git a/sources/pyside6/libpyside/pysideproperty.cpp b/sources/pyside6/libpyside/pysideproperty.cpp
index c00d90c2d..6d9769a7e 100644
--- a/sources/pyside6/libpyside/pysideproperty.cpp
+++ b/sources/pyside6/libpyside/pysideproperty.cpp
@@ -74,14 +74,14 @@ static PyObject *qProperty_freset(PyObject *, void *);
static PyObject *qProperty_fdel(PyObject *, void *);
static PyMethodDef PySidePropertyMethods[] = {
- {"getter", (PyCFunction)qPropertyGetter, METH_O, 0},
- {"setter", (PyCFunction)qPropertySetter, METH_O, 0},
- {"resetter", (PyCFunction)qPropertyResetter, METH_O, 0},
- {"deleter", (PyCFunction)qPropertyDeleter, METH_O, 0},
+ {"getter", reinterpret_cast<PyCFunction>(qPropertyGetter), METH_O, nullptr},
+ {"setter", reinterpret_cast<PyCFunction>(qPropertySetter), METH_O, nullptr},
+ {"resetter", reinterpret_cast<PyCFunction>(qPropertyResetter), METH_O, nullptr},
+ {"deleter", reinterpret_cast<PyCFunction>(qPropertyDeleter), METH_O, nullptr},
// Synonyms from Qt
- {"read", (PyCFunction)qPropertyGetter, METH_O, 0},
- {"write", (PyCFunction)qPropertySetter, METH_O, 0},
- {0, 0, 0, 0}
+ {"read", reinterpret_cast<PyCFunction>(qPropertyGetter), METH_O, nullptr},
+ {"write", reinterpret_cast<PyCFunction>(qPropertySetter), METH_O, nullptr},
+ {nullptr, nullptr, 0, nullptr}
};
static PyGetSetDef PySidePropertyType_getset[] = {
@@ -96,15 +96,15 @@ static PyGetSetDef PySidePropertyType_getset[] = {
};
static PyType_Slot PySidePropertyType_slots[] = {
- {Py_tp_dealloc, (void *)qpropertyDeAlloc},
- {Py_tp_call, (void *)qPropertyCall},
- {Py_tp_traverse, (void *)qpropertyTraverse},
- {Py_tp_clear, (void *)qpropertyClear},
- {Py_tp_methods, (void *)PySidePropertyMethods},
- {Py_tp_init, (void *)qpropertyTpInit},
- {Py_tp_new, (void *)qpropertyTpNew},
+ {Py_tp_dealloc, reinterpret_cast<void *>(qpropertyDeAlloc)},
+ {Py_tp_call, reinterpret_cast<void *>(qPropertyCall)},
+ {Py_tp_traverse, reinterpret_cast<void *>(qpropertyTraverse)},
+ {Py_tp_clear, reinterpret_cast<void *>(qpropertyClear)},
+ {Py_tp_methods, reinterpret_cast<void *>(PySidePropertyMethods)},
+ {Py_tp_init, reinterpret_cast<void *>(qpropertyTpInit)},
+ {Py_tp_new, reinterpret_cast<void *>(qpropertyTpNew)},
{Py_tp_getset, PySidePropertyType_getset},
- {0, 0}
+ {0, nullptr}
};
// Dotted modulename is crucial for SbkType_FromSpec to work. Is this name right?
static PyType_Spec PySidePropertyType_spec = {
@@ -183,7 +183,7 @@ static int qpropertyTpInit(PyObject *self, PyObject *args, PyObject *kwds)
static const char *kwlist[] = {"type", "fget", "fset", "freset", "fdel", "doc", "notify",
"designable", "scriptable", "stored",
- "user", "constant", "final", 0};
+ "user", "constant", "final", nullptr};
char *doc{};
if (!PyArg_ParseTupleAndKeywords(args, kwds,
@@ -514,7 +514,7 @@ PyObject *getValue(PySideProperty *self, PyObject *source)
PyTuple_SET_ITEM(args, 0, source);
return PyObject_CallObject(fget, args);
}
- return 0;
+ return nullptr;
}
int reset(PySideProperty *self, PyObject *source)
@@ -548,7 +548,7 @@ PySideProperty *getObject(PyObject *source, PyObject *name)
if (!attr)
PyErr_Clear(); //Clear possible error caused by PyObject_GenericGetAttr
- return 0;
+ return nullptr;
}
bool isReadable(const PySideProperty * /* self */)
@@ -558,12 +558,12 @@ bool isReadable(const PySideProperty * /* self */)
bool isWritable(const PySideProperty *self)
{
- return (self->d->fset != 0);
+ return self->d->fset != nullptr;
}
bool hasReset(const PySideProperty *self)
{
- return (self->d->freset != 0);
+ return self->d->freset != nullptr;
}
bool isDesignable(const PySideProperty *self)
diff --git a/sources/pyside6/libpyside/pysideqflags.cpp b/sources/pyside6/libpyside/pysideqflags.cpp
index b07a73332..3252aa9e6 100644
--- a/sources/pyside6/libpyside/pysideqflags.cpp
+++ b/sources/pyside6/libpyside/pysideqflags.cpp
@@ -72,7 +72,7 @@ extern "C" {
val = PyLong_AsLong(number);
} else {
PyErr_SetString(PyExc_TypeError,"QFlags must be created using enums or numbers.");
- return 0;
+ return nullptr;
}
}
PySideQFlagsObject *self = PyObject_New(PySideQFlagsObject, type);
@@ -96,7 +96,7 @@ extern "C" {
int result = 0;
if (!PyNumber_Check(other)) {
PyErr_BadArgument();
- return NULL;
+ return nullptr;
}
long valA = PYSIDE_QFLAGS(self)->ob_value;
@@ -126,13 +126,12 @@ extern "C" {
break;
default:
PyErr_BadArgument();
- return NULL;
+ return nullptr;
}
}
if (result)
Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
+ Py_RETURN_FALSE;
}
}
@@ -141,17 +140,17 @@ namespace PySide
namespace QFlags
{
static PyType_Slot SbkNewQFlagsType_slots[] = {
- {Py_nb_bool, 0},
- {Py_nb_invert, 0},
- {Py_nb_and, 0},
- {Py_nb_xor, 0},
- {Py_nb_or, 0},
+ {Py_nb_bool, nullptr},
+ {Py_nb_invert, nullptr},
+ {Py_nb_and, nullptr},
+ {Py_nb_xor, nullptr},
+ {Py_nb_or, nullptr},
{Py_nb_int, reinterpret_cast<void*>(qflag_int)},
{Py_nb_index, reinterpret_cast<void*>(qflag_int)},
- {Py_tp_new, (void *)PySideQFlagsNew},
- {Py_tp_richcompare, (void *)PySideQFlagsRichCompare},
- {Py_tp_dealloc, (void *)Sbk_object_dealloc},
- {0, 0}
+ {Py_tp_new, reinterpret_cast<void *>(PySideQFlagsNew)},
+ {Py_tp_richcompare, reinterpret_cast<void *>(PySideQFlagsRichCompare)},
+ {Py_tp_dealloc, reinterpret_cast<void *>(Sbk_object_dealloc)},
+ {0, nullptr}
};
static PyType_Spec SbkNewQFlagsType_spec = {
"missing QFlags name", // to be inserted later
@@ -185,7 +184,7 @@ namespace QFlags
PepType_PFTP(flagsType)->converterPtr = &PepType_PFTP(flagsType)->converter;
if (PyType_Ready(type) < 0)
- return 0;
+ return nullptr;
return type;
}
diff --git a/sources/pyside6/libpyside/pysidesignal.cpp b/sources/pyside6/libpyside/pysidesignal.cpp
index 63d5b0228..0eedae39c 100644
--- a/sources/pyside6/libpyside/pysidesignal.cpp
+++ b/sources/pyside6/libpyside/pysidesignal.cpp
@@ -103,8 +103,9 @@ static PyObject *metaSignalCheck(PyObject *, PyObject *);
static PyMethodDef MetaSignal_methods[] = {
- {"__instancecheck__", (PyCFunction)metaSignalCheck, METH_O|METH_STATIC, NULL},
- {0, 0, 0, 0}
+ {"__instancecheck__", reinterpret_cast<PyCFunction>(metaSignalCheck),
+ METH_O|METH_STATIC, nullptr},
+ {nullptr, nullptr, 0, nullptr}
};
static PyType_Slot PySideMetaSignalType_slots[] = {
@@ -112,7 +113,7 @@ static PyType_Slot PySideMetaSignalType_slots[] = {
{Py_tp_base, reinterpret_cast<void *>(&PyType_Type)},
{Py_tp_free, reinterpret_cast<void *>(PyObject_GC_Del)},
{Py_tp_dealloc, reinterpret_cast<void *>(Sbk_object_dealloc)},
- {0, 0}
+ {0, nullptr}
};
static PyType_Spec PySideMetaSignalType_spec = {
"2:PySide6.QtCore.MetaSignal",
@@ -145,7 +146,7 @@ static PyType_Slot PySideSignalType_slots[] = {
{Py_tp_new, reinterpret_cast<void *>(PyType_GenericNew)},
{Py_tp_free, reinterpret_cast<void *>(signalFree)},
{Py_tp_dealloc, reinterpret_cast<void *>(Sbk_object_dealloc)},
- {0, 0}
+ {0, nullptr}
};
static PyType_Spec PySideSignalType_spec = {
"2:PySide6.QtCore.Signal",
@@ -170,10 +171,11 @@ PyTypeObject *PySideSignalTypeF(void)
}
static PyMethodDef SignalInstance_methods[] = {
- {"connect", (PyCFunction)signalInstanceConnect, METH_VARARGS|METH_KEYWORDS, 0},
- {"disconnect", signalInstanceDisconnect, METH_VARARGS, 0},
- {"emit", signalInstanceEmit, METH_VARARGS, 0},
- {0, 0, 0, 0} /* Sentinel */
+ {"connect", reinterpret_cast<PyCFunction>(signalInstanceConnect),
+ METH_VARARGS|METH_KEYWORDS, nullptr},
+ {"disconnect", signalInstanceDisconnect, METH_VARARGS, nullptr},
+ {"emit", signalInstanceEmit, METH_VARARGS, nullptr},
+ {nullptr, nullptr, 0, nullptr} /* Sentinel */
};
static PyType_Slot PySideSignalInstanceType_slots[] = {
@@ -183,7 +185,7 @@ static PyType_Slot PySideSignalInstanceType_slots[] = {
{Py_tp_new, reinterpret_cast<void *>(PyType_GenericNew)},
{Py_tp_free, reinterpret_cast<void *>(signalInstanceFree)},
{Py_tp_dealloc, reinterpret_cast<void *>(Sbk_object_dealloc)},
- {0, 0}
+ {0, nullptr}
};
static PyType_Spec PySideSignalInstanceType_spec = {
"2:PySide6.QtCore.SignalInstance",
@@ -208,7 +210,7 @@ static int signalTpInit(PyObject *self, PyObject *args, PyObject *kwds)
char *argName = nullptr;
PyObject *argArguments = nullptr;
- if (emptyTuple == 0)
+ if (emptyTuple == nullptr)
emptyTuple = PyTuple_New(0);
if (!PyArg_ParseTupleAndKeywords(emptyTuple, kwds,
@@ -264,7 +266,7 @@ static void signalFree(void *self)
delete data->data;
data->data = nullptr;
Py_XDECREF(data->homonymousMethod);
- data->homonymousMethod = 0;
+ data->homonymousMethod = nullptr;
Py_TYPE(pySelf)->tp_base->tp_free(self);
}
@@ -286,7 +288,7 @@ static PyObject *signalGetItem(PyObject *self, PyObject *key)
static PyObject *signalToString(PyObject *self)
{
- return signalGetItem(self, 0);
+ return signalGetItem(self, nullptr);
}
static void signalInstanceFree(void *self)
@@ -300,10 +302,10 @@ static void signalInstanceFree(void *self)
if (dataPvt->next) {
Py_DECREF(dataPvt->next);
- dataPvt->next = 0;
+ dataPvt->next = nullptr;
}
delete dataPvt;
- data->d = 0;
+ data->d = nullptr;
Py_TYPE(pySelf)->tp_base->tp_free(self);
}
@@ -315,7 +317,7 @@ static PyObject *signalInstanceConnect(PyObject *self, PyObject *args, PyObject
if (!PyArg_ParseTupleAndKeywords(args, kwds,
"O|O:SignalInstance", const_cast<char **>(kwlist), &slot, &type))
- return 0;
+ return nullptr;
PySideSignalInstance *source = reinterpret_cast<PySideSignalInstance *>(self);
Shiboken::AutoDecRef pyArgs(PyList_New(0));
@@ -323,13 +325,13 @@ static PyObject *signalInstanceConnect(PyObject *self, PyObject *args, PyObject
bool match = false;
if (Py_TYPE(slot) == PySideSignalInstanceTypeF()) {
PySideSignalInstance *sourceWalk = source;
- PySideSignalInstance *targetWalk;
//find best match
while (sourceWalk && !match) {
- targetWalk = reinterpret_cast<PySideSignalInstance *>(slot);
+ auto targetWalk = reinterpret_cast<PySideSignalInstance *>(slot);
while (targetWalk && !match) {
- if (QMetaObject::checkConnectArgs(sourceWalk->d->signature, targetWalk->d->signature)) {
+ if (QMetaObject::checkConnectArgs(sourceWalk->d->signature,
+ targetWalk->d->signature)) {
PyList_Append(pyArgs, sourceWalk->d->source);
Shiboken::AutoDecRef sourceSignature(PySide::Signal::buildQtCompatible(sourceWalk->d->signature));
PyList_Append(pyArgs, sourceSignature);
@@ -413,7 +415,7 @@ static PyObject *signalInstanceConnect(PyObject *self, PyObject *args, PyObject
PySide::PyName::qtConnect()));
if (pyMethod.isNull()) { // PYSIDE-79: check if pyMethod exists.
PyErr_SetString(PyExc_RuntimeError, "method 'connect' vanished!");
- return 0;
+ return nullptr;
}
PyObject *result = PyObject_CallObject(pyMethod, tupleArgs);
if (result == Py_True || result == Py_False)
@@ -423,7 +425,7 @@ static PyObject *signalInstanceConnect(PyObject *self, PyObject *args, PyObject
if (!PyErr_Occurred()) // PYSIDE-79: inverse the logic. A Null return needs an error.
PyErr_Format(PyExc_RuntimeError, "Failed to connect signal %s.",
source->d->signature.constData());
- return 0;
+ return nullptr;
}
static int argCountInSignature(const char *signature)
@@ -487,7 +489,7 @@ static PyObject *signalInstanceGetItem(PyObject *self, PyObject *key)
PyErr_Format(PyExc_IndexError, "Signature %s not found for signal: %s",
sig.constData(), sigName.constData());
- return 0;
+ return nullptr;
}
static PyObject *signalInstanceDisconnect(PyObject *self, PyObject *args)
@@ -495,11 +497,9 @@ static PyObject *signalInstanceDisconnect(PyObject *self, PyObject *args)
auto source = reinterpret_cast<PySideSignalInstance *>(self);
Shiboken::AutoDecRef pyArgs(PyList_New(0));
- PyObject *slot;
+ PyObject *slot = Py_None;
if (PyTuple_Check(args) && PyTuple_GET_SIZE(args))
slot = PyTuple_GET_ITEM(args, 0);
- else
- slot = Py_None;
bool match = false;
if (Py_TYPE(slot) == PySideSignalInstanceTypeF()) {
@@ -534,13 +534,12 @@ static PyObject *signalInstanceDisconnect(PyObject *self, PyObject *args)
PyObject *result = PyObject_CallObject(pyMethod, tupleArgs);
if (!result || result == Py_True)
return result;
- else
- Py_DECREF(result);
+ Py_DECREF(result);
}
PyErr_Format(PyExc_RuntimeError, "Failed to disconnect signal %s.",
source->d->signature.constData());
- return 0;
+ return nullptr;
}
// PYSIDE-68: Supply the missing __get__ function
@@ -566,14 +565,15 @@ static PyObject *signalCall(PyObject *self, PyObject *args, PyObject *kw)
// An example is QProcess::error() (don't check the docs, but the source code of qprocess.h).
if (!signal->homonymousMethod) {
PyErr_SetString(PyExc_TypeError, "native Qt signal is not callable");
- return 0;
+ return nullptr;
}
descrgetfunc getDescriptor = Py_TYPE(signal->homonymousMethod)->tp_descr_get;
// Check if there exists a method with the same name as the signal, which is also a static
// method in C++ land.
- Shiboken::AutoDecRef homonymousMethod(getDescriptor(signal->homonymousMethod, 0, 0));
+ Shiboken::AutoDecRef homonymousMethod(getDescriptor(signal->homonymousMethod,
+ nullptr, nullptr));
if (PyCFunction_Check(homonymousMethod)
&& (PyCFunction_GET_FLAGS(homonymousMethod.object()) & METH_STATIC)) {
#if PY_VERSION_HEX >= 0x03090000
@@ -597,7 +597,8 @@ static PyObject *signalInstanceCall(PyObject *self, PyObject *args, PyObject *kw
}
descrgetfunc getDescriptor = Py_TYPE(PySideSignal->d->homonymousMethod)->tp_descr_get;
- Shiboken::AutoDecRef homonymousMethod(getDescriptor(PySideSignal->d->homonymousMethod, PySideSignal->d->source, 0));
+ Shiboken::AutoDecRef homonymousMethod(getDescriptor(PySideSignal->d->homonymousMethod,
+ PySideSignal->d->source, nullptr));
#if PY_VERSION_HEX >= 0x03090000
return PyObject_Call(homonymousMethod, args, kw);
#else
@@ -609,8 +610,7 @@ static PyObject *metaSignalCheck(PyObject * /* klass */, PyObject *arg)
{
if (PyType_IsSubtype(Py_TYPE(arg), PySideSignalInstanceTypeF()))
Py_RETURN_TRUE;
- else
- Py_RETURN_FALSE;
+ Py_RETURN_FALSE;
}
} // extern "C"
@@ -754,7 +754,7 @@ static void instanceInitialize(PySideSignalInstance *self, PyObject *name, PySid
const auto &signature = data->data->signatures.at(index);
selfPvt->signature = buildSignature(self->d->signalName, signature.signature);
selfPvt->attributes = signature.attributes;
- selfPvt->homonymousMethod = 0;
+ selfPvt->homonymousMethod = nullptr;
if (data->homonymousMethod) {
selfPvt->homonymousMethod = data->homonymousMethod;
Py_INCREF(selfPvt->homonymousMethod);
@@ -791,7 +791,7 @@ bool connect(PyObject *source, const char *signal, PyObject *callback)
if (result == Py_False) {
PyErr_Format(PyExc_RuntimeError, "Failed to connect signal %s, to python callable object.", signal);
Py_DECREF(result);
- result = 0;
+ result = nullptr;
}
return result;
}
@@ -818,8 +818,8 @@ PySideSignalInstance *newObjectFromMethod(PyObject *source, const QList<QMetaMet
selfPvt->signalName = cppName;
selfPvt->signature = m.methodSignature();
selfPvt->attributes = m.attributes();
- selfPvt->homonymousMethod = 0;
- selfPvt->next = 0;
+ selfPvt->homonymousMethod = nullptr;
+ selfPvt->next = nullptr;
}
return root;
}
@@ -869,7 +869,7 @@ static PyObject *buildQtCompatible(const QByteArray &signature)
void registerSignals(SbkObjectType *pyObj, const QMetaObject *metaObject)
{
- typedef QHash<QByteArray, QList<SignalSignature> > SignalSigMap;
+ using SignalSigMap = QHash<QByteArray, QList<SignalSignature> >;
SignalSigMap signalsFound;
for (int i = metaObject->methodOffset(), max = metaObject->methodCount(); i < max; ++i) {
QMetaMethod method = metaObject->method(i);
@@ -891,7 +891,7 @@ void registerSignals(SbkObjectType *pyObj, const QMetaObject *metaObject)
PySideSignal *self = PyObject_New(PySideSignal, PySideSignalTypeF());
self->data = new PySideSignalData;
self->data->signalName = it.key();
- self->homonymousMethod = 0;
+ self->homonymousMethod = nullptr;
// Empty signatures comes first! So they will be the default signal signature
std::stable_sort(it.value().begin(), it.value().end(), &compareSignals);
diff --git a/sources/pyside6/libpyside/pysideslot.cpp b/sources/pyside6/libpyside/pysideslot.cpp
index 81f93c555..cd81a9a39 100644
--- a/sources/pyside6/libpyside/pysideslot.cpp
+++ b/sources/pyside6/libpyside/pysideslot.cpp
@@ -70,11 +70,11 @@ static PyObject *slotCall(PyObject *, PyObject *, PyObject *);
// Class Definition -----------------------------------------------
static PyType_Slot PySideSlotType_slots[] = {
- {Py_tp_call, (void *)slotCall},
- {Py_tp_init, (void *)slotTpInit},
- {Py_tp_new, (void *)PyType_GenericNew},
- {Py_tp_dealloc, (void *)Sbk_object_dealloc},
- {0, 0}
+ {Py_tp_call, reinterpret_cast<void *>(slotCall)},
+ {Py_tp_init, reinterpret_cast<void *>(slotTpInit)},
+ {Py_tp_new, reinterpret_cast<void *>(PyType_GenericNew)},
+ {Py_tp_dealloc, reinterpret_cast<void *>(Sbk_object_dealloc)},
+ {0, nullptr}
};
static PyType_Spec PySideSlotType_spec = {
"2:PySide6.QtCore.Slot",
@@ -85,7 +85,7 @@ static PyType_Spec PySideSlotType_spec = {
};
-static PyTypeObject *PySideSlotTypeF(void)
+static PyTypeObject *PySideSlotTypeF()
{
static PyTypeObject *type = reinterpret_cast<PyTypeObject *>(
SbkType_FromSpec(&PySideSlotType_spec));
@@ -99,7 +99,7 @@ int slotTpInit(PyObject *self, PyObject *args, PyObject *kw)
char *argName = nullptr;
PyObject *argResult = nullptr;
- if (emptyTuple == 0)
+ if (emptyTuple == nullptr)
emptyTuple = PyTuple_New(0);
if (!PyArg_ParseTupleAndKeywords(emptyTuple, kw, "|sO:QtCore.Slot",
@@ -179,8 +179,7 @@ PyObject *slotCall(PyObject *self, PyObject *args, PyObject * /* kw */)
} // extern "C"
-namespace PySide {
-namespace Slot {
+namespace PySide::Slot {
static const char *Slot_SignatureStrings[] = {
"PySide6.QtCore.Slot(self,*types:type,name:str=nullptr,result:str=nullptr)->typing.Callable[...,typing.Optional[str]]",
@@ -195,5 +194,4 @@ void init(PyObject *module)
PyModule_AddObject(module, "Slot", reinterpret_cast<PyObject *>(PySideSlotTypeF()));
}
-} // namespace Slot
-} // namespace PySide
+} // namespace PySide::Slot
diff --git a/sources/pyside6/libpyside/pysideweakref.cpp b/sources/pyside6/libpyside/pysideweakref.cpp
index cd90634bd..bf37bbab7 100644
--- a/sources/pyside6/libpyside/pysideweakref.cpp
+++ b/sources/pyside6/libpyside/pysideweakref.cpp
@@ -52,9 +52,9 @@ typedef struct {
static PyObject *CallableObject_call(PyObject *callable_object, PyObject *args, PyObject *kw);
static PyType_Slot PySideCallableObjectType_slots[] = {
- {Py_tp_call, (void *)CallableObject_call},
- {Py_tp_dealloc, (void *)Sbk_object_dealloc},
- {0, 0}
+ {Py_tp_call, reinterpret_cast<void *>(CallableObject_call)},
+ {Py_tp_dealloc, reinterpret_cast<void *>(Sbk_object_dealloc)},
+ {0, nullptr}
};
static PyType_Spec PySideCallableObjectType_spec = {
"1:PySide.Callable",
@@ -86,10 +86,9 @@ namespace PySide { namespace WeakRef {
PyObject *create(PyObject *obj, PySideWeakRefFunction func, void *userData)
{
if (obj == Py_None)
- return 0;
+ return nullptr;
- if (Py_TYPE(PySideCallableObjectTypeF()) == 0)
- {
+ if (Py_TYPE(PySideCallableObjectTypeF()) == nullptr) {
Py_TYPE(PySideCallableObjectTypeF()) = &PyType_Type;
PyType_Ready(PySideCallableObjectTypeF());
}
@@ -97,11 +96,11 @@ PyObject *create(PyObject *obj, PySideWeakRefFunction func, void *userData)
PyTypeObject *type = PySideCallableObjectTypeF();
PySideCallableObject *callable = PyObject_New(PySideCallableObject, type);
if (!callable || PyErr_Occurred())
- return 0;
+ return nullptr;
PyObject *weak = PyWeakref_NewRef(obj, reinterpret_cast<PyObject *>(callable));
if (!weak || PyErr_Occurred())
- return 0;
+ return nullptr;
callable->weakref_func = func;
callable->user_data = userData;
diff --git a/sources/pyside6/libpyside/signalmanager.cpp b/sources/pyside6/libpyside/signalmanager.cpp
index 2c08f4328..87726facb 100644
--- a/sources/pyside6/libpyside/signalmanager.cpp
+++ b/sources/pyside6/libpyside/signalmanager.cpp
@@ -141,7 +141,8 @@ void PyObjectWrapper::reset(PyObject *o)
PyObjectWrapper &PyObjectWrapper::operator=(const PySide::PyObjectWrapper &other)
{
- reset(other.m_me);
+ if (this != &other)
+ reset(other.m_me);
return *this;
}
@@ -351,10 +352,9 @@ bool SignalManager::emitSignal(QObject *source, const char *signal, PyObject *ar
// if the signature doesn't have a '(' it's a shor circuited signal, i.e. std::find
// returned the string null terminator.
bool isShortCircuit = !*std::find(signal, signal + std::strlen(signal), '(');
- if (isShortCircuit)
- return emitShortCircuitSignal(source, signalIndex, args);
- else
- return MetaFunction::call(source, signalIndex, args);
+ return isShortCircuit
+ ? emitShortCircuitSignal(source, signalIndex, args)
+ : MetaFunction::call(source, signalIndex, args);
}
return false;
}
@@ -546,24 +546,21 @@ int SignalManager::registerMetaMethodGetIndex(QObject *source, const char *signa
if (!Shiboken::Object::hasCppWrapper(self)) {
qWarning() << "Invalid Signal signature:" << signature;
return -1;
- } else {
- auto pySelf = reinterpret_cast<PyObject *>(self);
- PyObject *dict = self->ob_dict;
- MetaObjectBuilder *dmo = metaBuilderFromDict(dict);
-
- // Create a instance meta object
- if (!dmo) {
- dmo = new MetaObjectBuilder(Py_TYPE(pySelf), metaObject);
- PyObject *pyDmo = PyCapsule_New(dmo, nullptr, destroyMetaObject);
- PyObject_SetAttr(pySelf, metaObjectAttr, pyDmo);
- Py_DECREF(pyDmo);
- }
-
- if (type == QMetaMethod::Signal)
- return dmo->addSignal(signature);
- else
- return dmo->addSlot(signature);
}
+ auto pySelf = reinterpret_cast<PyObject *>(self);
+ PyObject *dict = self->ob_dict;
+ MetaObjectBuilder *dmo = metaBuilderFromDict(dict);
+
+ // Create a instance meta object
+ if (!dmo) {
+ dmo = new MetaObjectBuilder(Py_TYPE(pySelf), metaObject);
+ PyObject *pyDmo = PyCapsule_New(dmo, nullptr, destroyMetaObject);
+ PyObject_SetAttr(pySelf, metaObjectAttr, pyDmo);
+ Py_DECREF(pyDmo);
+ }
+
+ return type == QMetaMethod::Signal
+ ? dmo->addSignal(signature) : dmo->addSlot(signature);
}
return methodIndex;
}
@@ -623,7 +620,7 @@ static PyObject *parseArguments(const QList<QByteArray>& paramTypes, void **args
} else {
PyErr_Format(PyExc_TypeError, "Can't call meta function because I have no idea how to handle %s", dataType);
Py_DECREF(preparedArgs);
- return 0;
+ return nullptr;
}
}
return preparedArgs;
diff --git a/sources/pyside6/tests/pysidetest/testobject.h b/sources/pyside6/tests/pysidetest/testobject.h
index c31a2ab73..2795cec5c 100644
--- a/sources/pyside6/tests/pysidetest/testobject.h
+++ b/sources/pyside6/tests/pysidetest/testobject.h
@@ -95,11 +95,11 @@ class PYSIDETEST_API TestObjectWithNamespace : public QObject
Q_OBJECT
public:
TestObjectWithNamespace(QObject* parent) : QObject(parent) {}
- QString name() { return "TestObjectWithNamespace"; }
+ QString name() { return QStringLiteral("TestObjectWithNamespace"); }
- void callSignal(TestObjectWithNamespace* obj) { emitSignal(obj); }
- void callSignalWithNamespace(TestObjectWithNamespace* obj) { emitSignalWithNamespace(obj); }
- void callSignalWithTypedef(int val) { emitSignalWithTypedef(val); }
+ void callSignal(TestObjectWithNamespace* obj) { emit emitSignal(obj); }
+ void callSignalWithNamespace(TestObjectWithNamespace* obj) { emit emitSignalWithNamespace(obj); }
+ void callSignalWithTypedef(int val) { emit emitSignalWithTypedef(val); }
signals:
void emitSignal(TestObjectWithNamespace* obj);
@@ -114,7 +114,7 @@ class PYSIDETEST_API TestObject2WithNamespace : public QObject
Q_OBJECT
public:
TestObject2WithNamespace(QObject* parent) : QObject(parent) {}
- QString name() { return "TestObject2WithNamespace"; }
+ QString name() { return QStringLiteral("TestObject2WithNamespace"); }
};
PYSIDETEST_API QDebug operator<<(QDebug dbg, TestObject2WithNamespace& testObject);
@@ -134,7 +134,7 @@ class PYSIDETEST_API TestObjectWithoutNamespace : public QObject
public:
enum Enum2 { Option3 = 3, Option4 = 4};
TestObjectWithoutNamespace(QObject* parent) : QObject(parent) {}
- QString name() { return "TestObjectWithoutNamespace"; }
+ QString name() { return QStringLiteral("TestObjectWithoutNamespace"); }
void callSignal(TestObjectWithoutNamespace* obj) { emitSignal(obj); }
void callSignalWithNamespace(TestObjectWithoutNamespace* obj) { emitSignalWithNamespace(obj); }
diff --git a/sources/pyside6/tests/pysidetest/testview.cpp b/sources/pyside6/tests/pysidetest/testview.cpp
index 49e3730f5..110a87ac2 100644
--- a/sources/pyside6/tests/pysidetest/testview.cpp
+++ b/sources/pyside6/tests/pysidetest/testview.cpp
@@ -44,9 +44,9 @@ QWidget*
TestView::getEditorWidgetFromItemDelegate() const
{
if (!m_delegate)
- return 0;
+ return nullptr;
QModelIndex index;
QStyleOptionViewItem options;
- return m_delegate->createEditor(0, options, index);
+ return m_delegate->createEditor(nullptr, options, index);
}
diff --git a/sources/shiboken6/tests/libsample/objecttype.cpp b/sources/shiboken6/tests/libsample/objecttype.cpp
index a0bf257b8..e5926d0c2 100644
--- a/sources/shiboken6/tests/libsample/objecttype.cpp
+++ b/sources/shiboken6/tests/libsample/objecttype.cpp
@@ -220,7 +220,7 @@ ObjectTypeLayout* ObjectType::takeLayout()
if (!l)
return nullptr;
m_layout = nullptr;
- l->setParent(0);
+ l->setParent(nullptr);
return l;
}