-
Notifications
You must be signed in to change notification settings - Fork 489
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
Add support for weak references #745
Conversation
@@ -140,6 +140,8 @@ impl Delegate { | |||
::std::ptr::null_mut() | |||
}; | |||
|
|||
// TODO: implement IMarshal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: it would be nice to track these as issues instead of todos in the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
impl TearOff { | ||
unsafe fn new(object: RawPtr, strong_count: u32) -> IWeakReferenceSource { | ||
std::mem::transmute(::std::boxed::Box::new(TearOff { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this code generated at some point? I don't think we need the fully qualified paths here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, its just not obvious what types are automatically included.
} | ||
|
||
impl TearOff { | ||
unsafe fn new(object: RawPtr, strong_count: u32) -> IWeakReferenceSource { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be really great to document these unsafe functions invariants.
Weak references enable COM objects to support non-owning references, allowing an object to be used only if some other strong reference is keeping the object alive. This can be useful for breaking reference cycles. This is required to support Xaml/WinUI and part of the larger support for #81. Implementations based on the
implement
macro now support weak references automatically.Fixes #366