Skip to content

Missing impl Constructor<()> for ... {} in the bridge silently fails #1233

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

Open
LeonMatthesKDAB opened this issue Mar 20, 2025 · 0 comments
Open
Labels
⏮️ backport-candidate Change which could be backported to the stable series 🤔 discussion Feedback welcome

Comments

@LeonMatthesKDAB
Copy link
Collaborator

If you miss adding the impl Constructor for ... shim trait impl in the bridge, but implement the trait outside the bridge, you don't get a warning, CXX-Qt will just skip using your constructor.

This is especially bad in combination with cxx_qt::Initialize, as that requires you to declare a default constructor, which you also get if you don't add the declaration, but the one generated by CXX-Qt won't actually call your initialize function.

Idea to remedy this

We could introduce a new trait: ConstructorDeclaration<()> (name TBD), where Constructor requires ConstructorDeclaration.
And ConstructorDeclaration would only be implemented by the bridge if you add impl Constructor<()> for ... {}.

That way you would get a compiler error if you implement the Constructor or Initialize trait without declaring it in the bridge.

@LeonMatthesKDAB LeonMatthesKDAB added ⏮️ backport-candidate Change which could be backported to the stable series 🤔 discussion Feedback welcome labels Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⏮️ backport-candidate Change which could be backported to the stable series 🤔 discussion Feedback welcome
Projects
None yet
Development

No branches or pull requests

1 participant