Skip to content

Qt 6.9: Return type for QObjectData_dynamicMetaObject is now const #195

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

Merged
merged 4 commits into from
Apr 11, 2025

Conversation

rcalixte
Copy link
Contributor

@rcalixte
Copy link
Contributor Author

The macro is copied but shouldn't represent a licensing issue. I added the comment so that it would be clear. Feel free to modify it as needed.

@mappu
Copy link
Owner

mappu commented Apr 11, 2025

Thanks for the quick PR! LGTM 🚢

@mappu mappu merged commit c2e299d into mappu:master Apr 11, 2025
9 checks passed
@@ -36,7 +36,13 @@ void miqt_exec_callback_QObject_disconnectNotify(QObject*, intptr_t, QMetaMethod
} /* extern C */
#endif

// This method's return type was changed from non-const to const in Qt 6.9
#if QT_VERSION >= QT_VERSION_CHECK(6,9,0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can technically return the const pointer for all qt versions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this a type mismatch if the underlying type isn't const? And couldn't it lead to undefined behavior on Qt versions under 6.9?

Ultimately, this is a stop-gap of sorts. Once we start building on a version at or above Qt 6.9, the patches in config-allowlist.go can go away. (It probably makes sense to leave the remaining code... just in case. 😅)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once we start building

An interesting approach would actually be to generate the bindings for each qt version separately and use the #if trick for any "new" features - ie one would start with 6.0 generating all of that, then gradually add each version as it happens, hidden behind #if - then the mappings could / would work with any qt version that the user happens to have installed.

Isn't this a type mismatch

you can assign a non-const pointer to a const pointer of the same underlying type without issue, in general - the other direction is not allowed though.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As well as running genbindings on every version of Qt and diffing/merging the results, the other step would be to run it for clang-linux, clang-mingw, and clang-osxcross to identify all the cross-platform functions (#59).

@rcalixte rcalixte deleted the qt69_const branch April 11, 2025 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Qt 6.9 not compiling - QObjectData_dynamicMetaObject invalid conversion from const
3 participants