You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 11, 2024. It is now read-only.
When you run it, you get thread 'main' panicked at 'Underflow of reference count'.
The problem is that the DoSomething method of SomethingClass takes an owned IEmpty, and thus will implicitly drop it, which decreases the reference count. But this is not what should happen. The callee should not call Release on its parameters; in fact it should call AddRef if it needs to access the interface after the call completes. The caller ensures that the interface is valid during the duration of the call.
To solve this, the marked line should be replaced with the following:
fnDoSomething(&self,_empty:&IEmpty){}
However this does not compile.
As a temporary workaround, you can call std::mem::forget(_empty) in the class method.