-
Bug
-
Resolution: Done
-
Not Evaluated
-
None
-
5.15.2
-
None
-
-
e1a2fd9524 (pyside/pyside-setup/dev) e1a2fd9524 (pyside/tqtc-pyside-setup/dev) e1a2fd9524 (pyside/tqtc-pyside-setup/tqtc/dev) e1a2fd9524 (pyside/pyside-setup/6.4), aa0969f57 (tqtc/lts-6.2)
Accessing enums via reference or pointer causes the generated python bindings to either not compile or to silently crash.
Test code
enum TestEnum
{
ENUM_VALUE_1 = 1,
ENUM_VALUE_2 = 2,
ENUM_VALUE_3 = 3
};
struct TestCases
{
void test_08(TestEnum& e)
{
std::cout << "TestEnum& e = " << e << std::endl;
}
void test_09(TestEnum* e)
{
std::cout << "TestEnum* e = " << *e << std::endl;
}
};
Case 1: Reference to enum
test_08 does not compile
error C2664: 'void TestCases::test_08(TestEnum &)': cannot convert argument 1 from 'TestEnum *' to 'TestEnum &'
generated code
// Call function/method
{
::TestEnum *cppArg0;
pythonToCpp(pyArg, &cppArg0);
if (!PyErr_Occurred()) {
// test_08(TestEnum&)
cppSelf->test_08(cppArg0); // <--- test_08 accepts a reference
}
}
possible solution
Dereferencing the pointer works, but leads to the same crash described in case 2
cppSelf->test_08(*cppArg0);
Case 2: Pointer to enum
test_09 silently crashes in python
Python program exits without any output, probably due to memory corruption on the C++ side
The generated code for test_09
// Call function/method
{
::TestEnum *cppArg0;
pythonToCpp(pyArg, &cppArg0);
if (!PyErr_Occurred()) {
// test_09(TestEnum*)
cppSelf->test_09(cppArg0);
}
}
possible solution
Apparently, removing the referencing in the pythonToCpp call seems to fix the issue.
pythonToCpp(pyArg, cppArg0);
| For Gerrit Dashboard: PYSIDE-2065 | ||||||
|---|---|---|---|---|---|---|
| # | Subject | Branch | Project | Status | CR | V |
| 435177,20 | shiboken6: Introduce a helper for dereferencing arguments | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |
| 435198,17 | WIP: shiboken6: Use indirections from python conv | dev | pyside/pyside-setup | Status: ABANDONED | -2 | 0 |
| 435279,19 | shiboken6: Fix indirections of enums/flag arguments | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |
| 435280,16 | WIP: shiboken6: Use struct GeneratorArgument | dev | pyside/pyside-setup | Status: ABANDONED | -2 | 0 |
| 435289,15 | WIP: shiboken6: Remove AbstractMetaType::shouldDereferenceArgument() | dev | pyside/pyside-setup | Status: ABANDONED | -2 | 0 |
| 435471,6 | shiboken6: Add an option to print primitive type entries | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |
| 435773,2 | shiboken6: Add a test for passing enums by pointer | dev | pyside/pyside-setup | Status: ABANDONED | 0 | 0 |
| 435795,2 | shiboken6: Replace pyIntT() by pyLongT() | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |
| 436015,2 | shiboken6: Replace pyIntT() by pyLongT() | 6.3 | pyside/pyside-setup | Status: MERGED | +2 | 0 |
| 436140,3 | shiboken6: Replace pyIntT() by pyLongT() | tqtc/lts-6.2 | pyside/tqtc-pyside-setup | Status: MERGED | +2 | 0 |