Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gui: PythonWrapper: Do not steal reference (fixes #12542) #12576

Merged
merged 1 commit into from
Feb 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Gui/PythonWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@

void toCppPointerConvFuncQuantity(PyObject* pyobj,void* cpp)
{
*static_cast<Base::Quantity*>(cpp) = *static_cast<Base::QuantityPy*>(pyobj)->getQuantityPtr();

Check warning on line 222 in src/Gui/PythonWrapper.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

do not use static_cast to downcast from a base to a derived class [cppcoreguidelines-pro-type-static-cast-downcast]
}

PythonToCppFunc toCppPointerCheckFuncQuantity(PyObject* obj)
Expand All @@ -232,8 +232,8 @@

void BaseQuantity_PythonToCpp_QVariant(PyObject* pyIn, void* cppOut)
{
Base::Quantity* q = static_cast<Base::QuantityPy*>(pyIn)->getQuantityPtr();

Check warning on line 235 in src/Gui/PythonWrapper.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

variable name 'q' is too short, expected at least 2 characters [readability-identifier-length]

Check warning on line 235 in src/Gui/PythonWrapper.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

do not use static_cast to downcast from a base to a derived class [cppcoreguidelines-pro-type-static-cast-downcast]
*((QVariant*)cppOut) = QVariant::fromValue<Base::Quantity>(*q);

Check warning on line 236 in src/Gui/PythonWrapper.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

do not use C-style cast to convert between unrelated types [cppcoreguidelines-pro-type-cstyle-cast]
}

PythonToCppFunc isBaseQuantity_PythonToCpp_QVariantConvertible(PyObject* obj)
Expand All @@ -245,11 +245,11 @@
}

#if defined (HAVE_PYSIDE)
Base::Quantity convertWrapperToQuantity(const PySide::PyObjectWrapper &w)

Check warning on line 248 in src/Gui/PythonWrapper.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

parameter name 'w' is too short, expected at least 2 characters [readability-identifier-length]
{
auto pyIn = static_cast<PyObject*>(w);
if (PyObject_TypeCheck(pyIn, &(Base::QuantityPy::Type))) {
return *static_cast<Base::QuantityPy*>(pyIn)->getQuantityPtr();

Check warning on line 252 in src/Gui/PythonWrapper.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

do not use static_cast to downcast from a base to a derived class [cppcoreguidelines-pro-type-static-cast-downcast]
}

return Base::Quantity(std::numeric_limits<double>::quiet_NaN());
Expand Down Expand Up @@ -330,7 +330,7 @@
# endif
#else
# if defined (HAVE_SHIBOKEN2)
return reinterpret_cast<SbkObjectType*>(Shiboken::SbkType<qttype>());

Check warning on line 333 in src/Gui/PythonWrapper.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

do not use reinterpret_cast [cppcoreguidelines-pro-type-reinterpret-cast]
# else
return Shiboken::SbkType<qttype>();
# endif
Expand All @@ -343,8 +343,8 @@
auto type = getPyTypeObjectForTypeName<qttype>();
if (type) {
if (Shiboken::Object::checkType(pyobj)) {
auto skbobj = reinterpret_cast<SbkObject *>(pyobj);

Check warning on line 346 in src/Gui/PythonWrapper.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

do not use reinterpret_cast [cppcoreguidelines-pro-type-reinterpret-cast]
auto pytypeobj = reinterpret_cast<PyTypeObject *>(type);

Check warning on line 347 in src/Gui/PythonWrapper.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

do not use reinterpret_cast [cppcoreguidelines-pro-type-reinterpret-cast]
return static_cast<qttype*>(Shiboken::Object::cppPointer(skbobj, pytypeobj));
}
}
Expand All @@ -365,7 +365,7 @@
* lineedit.show()
* \endcode
*/
class WrapperManager : public QObject

Check warning on line 368 in src/Gui/PythonWrapper.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

class 'WrapperManager' defines a default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
{

public:
Expand Down Expand Up @@ -472,7 +472,7 @@
Py::Callable func = mainmod.getDict().getItem("getCppPointer");

Py::Tuple arguments(1);
arguments[0] = Py::asObject(pyobj); // PySide pointer
arguments[0] = Py::Object(pyobj); // PySide pointer
Py::Tuple result(func.apply(arguments));
return reinterpret_cast<qttype*>(PyLong_AsVoidPtr(result[0].ptr()));
}
Expand Down