-
Notifications
You must be signed in to change notification settings - Fork 247
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
Bug: Inheriting winrt::implements can't get weak_ref #1453
Comments
This looks like #1312. Is your cppwinrt up to date? |
I don't have a good understanding of this area but it seems like the inheritance is confusing things. If I change your example to this then it compiles for me. The change is to modify the type signature of the weak reference from int main(int const, char**)
{
winrt::init_apartment();
{
auto mycoclass_instance{ winrt::make_self<MyCoclass2>() };
winrt::weak_ref<MyCoclass> weak(mycoclass_instance);
auto weakval = weak.get();
}
} I was able to repro the break on the latest stable release of cppwinrt (April 2024). I did have to tweak a few things in your code sample to get it to compile (e.g. arguments to |
One problem is the presence of two winrt::implements in the inheritance hierarchy. There should only be one. I'd remove it from MyCoClass2, in favor of directly inheriting from MyCoClass. But even removing that, it won't compile. The repro can also be changed to avoid int main(int const argc, char** argv)
{
winrt::init_apartment();
{
auto mycoclass_instance{ winrt::make<MyCoclass2>() };
winrt::get_self<MyCoclass2>(mycoclass_instance);
}
} |
yes the problem is get_self |
Version
No response
Summary
Inheriting winrt::implements can't get weak_ref
'static_cast' : cannot convert from 'winrt::impl::producer<T,IMyComInterface1,void> *' to 'T *'
how to resolve this error
Reproducible example
Expected behavior
No response
Actual behavior
No response
Additional comments
No response
The text was updated successfully, but these errors were encountered: