<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hello,</p>
<p>I encountered a compatibility issue when building PyQt 6.11.0
against Qt 6.11.2 for Android using python-for-android.<br>
I then let my coding harness analyze the issue and it came up with
a patch and the issue description below. I don't fully understand
but it might be helpful for you to fix a bug:</p>
<p>Environment </p>
<p>- PyQt 6.11.0<br>
- Qt 6.11.2<br>
- Python 3.11.15<br>
- Android NDK r28c, Clang 19<br>
- x86_64 APK running on an Android 9 emulator </p>
<p>A Python slot declared with @pyqtSlot(result=str) returns
undefined when invoked from QML. In my application, passing that
result to another slot accepting a string produces an empty string
and subsequently a<br>
KeyError. </p>
<p>### Apparent cause </p>
<p>Qt 6.11.2 added a QMetaMethod::MethodType _type member to
QMetaMethodBuilder: </p>
<p><a
href="https://github.com/qt/qtbase/commit/a598cc13db785acc6fe85ee5f54735557d878bcc"
class="external-link moz-txt-link-freetext" target="_blank"
rel="noopener nofollow">https://github.com/qt/qtbase/commit/a598cc13db785acc6fe85ee5f54735557d878bcc</a>
</p>
<p>However, PyQt’s copied declaration in: </p>
<p>qpy/QtCore/qpycore_qmetaobjectbuilder.h </p>
<p>still contains only: </p>
<p>const QMetaObjectBuilder *_mobj;<br>
int _index; </p>
<p>On x86_64, the new field occupies bytes previously considered
padding. Clang can discard those bytes when receiving a builder
returned by Qt. Qt subsequently reads an invalid _type, causing
setReturnType() to<br>
silently do nothing. The generated slot metadata therefore remains
void, and QML receives undefined. </p>
<p>### Independent reproduction </p>
<p>A focused C++ test using PyQt’s copied header and the actual Qt
6.11.2 library calls: </p>
<p>auto slot = builder.addSlot("startWizard()");<br>
slot.setReturnType("QString"); </p>
<p>It then inspects the method produced by builder.toMetaObject(). </p>
<p>With deliberately nonzero backing storage to expose the missing
field deterministically: </p>
<p>Compiler Original declaration
Corrected declaration<br>
━━━━━━━━━━━━━━━ ━━━━━━━━━━━━━━━━━━━━━━ ━━━━━━━━━━━━━━━━━━━━━━━<br>
Clang 19, -O2 Return type void Return
type QString<br>
─────────────── ────────────────────── ───────────────────────<br>
GCC, -O2 Return type QString Return
type QString </p>
<p>GCC happens to preserve the relevant bytes in this reproduction.
Clang also exhibits the failure with optimizations disabled. </p>
<p>### Proposed correction </p>
<p>Include and add the following member immediately after _index in
PyQt’s QMetaMethodBuilder declaration: </p>
<p><a class="tag" href="#if">#if</a> QT_VERSION >=
QT_VERSION_CHECK(6, 11, 2)<br>
QMetaMethod::MethodType _type = QMetaMethod::Method;<br>
<a class="tag" href="#endif">#endif</a> </p>
<p>This restores the correct return metadata in the focused Clang
reproduction. Verification of the patched Android APK is still
pending. </p>
<p>I also checked the official 6.11.1.dev2609111110 source snapshot;
its copied header is unchanged and still lacks this member. </p>
<p>Could this declaration be updated in an upcoming PyQt release? </p>
<p>Thank you.</p>
<p><br>
</p>
</body>
</html>