I try to demo something by directshow recently. When working with filter, I made some mistake in accident today. I did something like UnAdviseFooEventSink in the destrucotr of event object. Let`s check what happen :
- when the event sink object is created, the reference count should be 1.
- when Foo Advise the sink object, reference count of sink object increase to 2.
- when I don`t need the sink object anymore and try to release it, reference count decrease to 1.
- Now the owner of the sink object is Foo, and I wish sink object to be UnAdvise when being deleted.
- Since Foo is still the owner of sink object, sink object won`t be deleted if Foo doesn`t do extra work.
Thanks for the debugging function of baseclass of dshow, I got some ugly assert and try to fix it.
BTW, the same isuue would happen in cocoa of Mac, too. If 2 objects are the owner of each other (retain each other), they should be disconnected before release the final reference outside of the scope.
No comments:
Post a Comment