<div dir="ltr">Hi Huw,<div><br></div><div>This is a newer version:</div><div><div>static HRESULT CreateITextRange(IRichEditOle *reOle, LONG start, LONG end,</div><div>                                ITextRangeImpl *txtRge, ITextRange** ppRange)</div><div>{</div><div>    IRichEditOleImpl *reOleImpl = impl_from_IRichEditOle(reOle);</div><div><br></div><div>    txtRge->ITextRange_iface.lpVtbl = &trvt;</div><div>    txtRge->ref = 1;</div><div>    IRichEditOle_AddRef(reOle);</div><div>    txtRge->reOle = reOleImpl;</div><div>    txtRge->start = start;</div><div>    txtRge->end = end;</div><div>    list_add_head(&reOleImpl->rangelist, &txtRge->entry);</div><div>    *ppRange = &txtRge->ITextRange_iface;</div><div>    return S_OK;</div><div>}</div></div><div><br></div><div>I will prefer passing ITextRangeImpl into CreateITextRange instead of ITextRange interface.</div><div>So we don't need to impl_from_ITextRange again. Is it also ok?</div><div><br></div><div>btw, I didn't alloc txtRge (txtRge = heap_alloc(sizeof(ITextRangeImpl));) in CreateITextRange(),</div><div>because CreateITextRange() was just created for sharing code with ITextRange::GetDuplicate and GetDuplicate</div><div>will return E_FAIL for all any other error[0] when ITextDocument::Range returning E_OUTOFMEMORY.[1]</div><div><br></div><div>Thanks.</div><div><br></div><div>[0] <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb787840(v=vs.85).aspx">http://msdn.microsoft.com/en-us/library/windows/desktop/bb787840(v=vs.85).aspx</a></div><div>[1] <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb774097(v=vs.85).aspx">http://msdn.microsoft.com/en-us/library/windows/desktop/bb774097(v=vs.85).aspx</a></div></div><div class="gmail_extra"><br><div class="gmail_quote">2014-09-12 15:53 GMT+08:00 Huw Davies <span dir="ltr"><<a href="mailto:huw@codeweavers.com" target="_blank">huw@codeweavers.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Fri, Sep 12, 2014 at 10:47:44AM +0800, Jactry Zeng wrote:<br>
><br>
> 2014-09-12 4:43 GMT+08:00 Sebastian Lackner <<a href="mailto:sebastian@fds-team.de">sebastian@fds-team.de</a>>:<br>
> ><br>
> ><br>
> > Are you sure? Doesn't this test below show exactly the opposite? It seems to<br>
> be safe<br>
> > to release the ITextDocument, and afterwards call an ITextRange function - it<br>
> will just<br>
> > return CO_E_RELEASED since the parent object was already released. Or am I<br>
> misunderstanding<br>
> > this code?<br>
><br>
> So sorry, I made a mistake yesterday here. I added more a ITextRange::Release<br>
> before the ITextRange calling<br>
> in my new tests code yesterday.<br>
> Functions of ITextRange will return CO_E_RELEASED after reOle/txtDoc were<br>
> released and will<br>
> crash after the ITextRange was released.<br>
<br>
</div></div>In that case let's go with your proposed implementation.<br>
<span class="HOEnZb"><font color="#888888"><br>
Huw.<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><div>Regards,<br></div><div>Jactry Zeng</div><div><br></div></div>
</div>