<div dir="ltr"><div class="gmail_extra">Hi Huw,<br>2014-06-25 19:18 GMT+08:00 Huw Davies <<a href="mailto:huw@codeweavers.com" target="_blank">huw@codeweavers.com</a>>:<br>><br>> > diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c<br>




> > index 2af2582..65e70fa 100644<br>> > --- a/dlls/riched20/editor.c<br>> > +++ b/dlls/riched20/editor.c<br>> > @@ -4468,6 +4468,13 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,<br>




> >    case EM_GETOLEINTERFACE:<br>> >    {<br>> >      LPVOID *ppvObj = (LPVOID*) lParam;<br>> > +    if (editor->reOle)<br>> > +    {<br>> > +        *ppvObj = editor->reOle;<br>




> > +        IRichEditOle_AddRef(*ppvObj);<br>> > +        return 1;<br>> > +    }<br>> > +<br>> >      return CreateIRichEditOle(editor, ppvObj);<br>> >    }<br>> >    case EM_GETPASSWORDCHAR:<br>




><br>><br>> Better to assign editor->reOle here too.<br>> That will be one ref, then every returned iface should add<br>> another ref.  So the first iface returned will have<br>> refcount of 2 and then your tests will pass.<br>




><br>> You release the final ref in the editor destructor.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Is this the right way? :</div><div class="gmail_extra"><br></div><div class="gmail_extra">


<div class="gmail_extra">@@ -4468,7 +4468,20 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,</div><div class="gmail_extra">   case EM_GETOLEINTERFACE:</div><div class="gmail_extra">   {</div><div class="gmail_extra">


     LPVOID *ppvObj = (LPVOID*) lParam;</div><div class="gmail_extra">-    return CreateIRichEditOle(editor, ppvObj);</div><div class="gmail_extra">+    if (editor->reOle)</div><div class="gmail_extra">+    {</div><div class="gmail_extra">


+        *ppvObj = editor->reOle;</div><div class="gmail_extra">+        IRichEditOle_AddRef(*ppvObj);</div><div class="gmail_extra">+        return 1;</div><div class="gmail_extra">+    }</div><div class="gmail_extra">


+</div><div class="gmail_extra">+    if (CreateIRichEditOle(editor, ppvObj))</div><div class="gmail_extra">+    {</div><div class="gmail_extra">+        editor->reOle = *ppvObj;</div><div class="gmail_extra">+        IRichEditOle_AddRef(*ppvObj);</div>


<div class="gmail_extra">+        return 1;</div><div class="gmail_extra">+    }</div><div class="gmail_extra">+    return 0;</div><div class="gmail_extra">   }</div></div><div class="gmail_extra"><br></div><div class="gmail_extra">


ref will be one when created, and will increase every time returned iface.</div>
<div class="gmail_extra">And in this way, IRichEditOle_fnRelease also should be modified:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra"><div class="gmail_extra">@@ -126,12 +126,13 @@ IRichEditOle_fnRelease(IRichEditOle *me)</div>


<div class="gmail_extra"><br></div><div class="gmail_extra">     TRACE ("%p ref=%u\n", This, ref);</div><div class="gmail_extra"><br></div><div class="gmail_extra">-    if (!ref)</div><div class="gmail_extra">+    if (ref == 1)</div>


<div class="gmail_extra">     {</div><div class="gmail_extra">         TRACE ("Destroying %p\n", This);</div><div class="gmail_extra">         This->txtSel->reOle = NULL;</div><div class="gmail_extra">         ITextSelection_Release(&This->txtSel->ITextSelection_iface);</div>


<div class="gmail_extra">         IOleClientSite_Release(&This->clientSite->IOleClientSite_iface);</div><div class="gmail_extra">+        This->editor->reOle = NULL;</div><div class="gmail_extra">         heap_free(This);</div>


<div class="gmail_extra">     }</div><div class="gmail_extra">     return ref;</div></div></div><div class="gmail_extra"><br>><br>> > diff --git a/dlls/riched20/editstr.h b/dlls/riched20/editstr.h<br>
> > index f139c29..3722c82 100644<br>> > --- a/dlls/riched20/editstr.h<br>> > +++ b/dlls/riched20/editstr.h<br>> > @@ -388,6 +388,7 @@ typedef struct tagME_TextEditor<br>> >  {<br>> >    HWND hWnd, hwndParent;<br>




> >    ITextHost *texthost;<br>> > +  LPVOID reOle;<br>><br>> Needs correct type.<br><br><div class="gmail_extra">@@ -388,6 +388,7 @@ typedef struct tagME_TextEditor</div><div class="gmail_extra"> {</div>


<div class="gmail_extra">   HWND hWnd, hwndParent;</div><div class="gmail_extra">   ITextHost *texthost;</div><div class="gmail_extra">+  IRichEditOle *reOle;</div><div class="gmail_extra">   BOOL bEmulateVersion10;</div>


<div class="gmail_extra">   ME_TextBuffer *pBuffer;</div><div class="gmail_extra">   ME_Cursor *pCursors;</div><br clear="all"><div><br></div><div>Thanks again!</div>-- <br><div dir="ltr"><div>Regards,<br></div><div>Jactry Zeng</div>


<div><br></div>

</div>
</div></div>