<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">Am 26.03.2018 um 06:12 schrieb Kieran Duggan <<a href="mailto:kieranduggan15@gmail.com" class="">kieranduggan15@gmail.com</a>>:</div><br class="Apple-interchange-newline"><div class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class=""><div class="">The hard part of this for me was figuring out who was responsible for freeing container. After some time I came to the conclusion that the caller of<br class=""></div>the AtlAxAttachControl function was intended to free container. I namely came to this conclusion because I couldn't really see how the DestroyWindow<br class=""></div>function would be able to free the container. If DestoyWindow is supposed to be responsible for freeing container, I just wasn't<span class="Apple-converted-space"> </span><br class=""></div><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">smart enough to figure it out and will have too look again.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></blockquote></div>As far as I can tell (and I haven't touched the atl code myself before) your conclusion is correct. AtlAxAttachControl creates the container object and returns the interface, so the caller is responsible for eventually destroying it. I would say submit your patch :-) . And don't forget to submit your gsoc proposal in time on the google website!<div class=""><br class=""></div><div class="">Ignore the following if it confuses you. It's some semi-educated guesswork on my part:</div><div class=""><br class=""></div><div class="">DestroyWindow doesn't know anything about COM or atl, so the DestroyWindow implementation is certainly not the right place. However, one thing is theoretically possible: DestroyWindow will send WM_DESTROY to the window callback procedure, which could in theory be responsible for releasing the container. AtlAxAttachControl appears to overwrite the wndproc (in IOCS_Attach). IOCS_Detach might be a candidate for releasing the container, it is called on WM_DESTROY.</div><div class=""><br class=""></div><div class="">However, I think this is unlikely because AtlAxAttachControl returns the interface to the caller. And convention says that the caller that receives an interface must release it once it is done. Of course Microsoft screws up its own COM rules a lot.</div><div class=""><br class=""></div><div class="">You can try to do to find out by looking at how Windows behaves when it is running this test: You can read the reference count by calling AddRef() followed by Release(). (there is a function get_refcount in numerous places, e.g. dlls/ddraw/tests). After AtlAxAttachControl I'd expect it to be 1. If it is still 1 after DestroyWindow(), the window callbacks should leave the refcount alone. If trying to call AddRef() after DestroyWindow crashes, or the refcount is zero, something in the window procedure released the container.</div><div class=""><br class=""></div></body></html>