[PATCH] riched20: Don't create too many IRichEditOle interfaces for a RichEdit. (try 2)

Huw Davies huw at codeweavers.com
Wed Jun 25 06:18:38 CDT 2014


On Wed, Jun 25, 2014 at 06:56:00PM +0800, Jactry Zeng wrote:

> diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
> index 2af2582..65e70fa 100644
> --- a/dlls/riched20/editor.c
> +++ b/dlls/riched20/editor.c
> @@ -4468,6 +4468,13 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
>    case EM_GETOLEINTERFACE:
>    {
>      LPVOID *ppvObj = (LPVOID*) lParam;
> +    if (editor->reOle)
> +    {
> +        *ppvObj = editor->reOle;
> +        IRichEditOle_AddRef(*ppvObj);
> +        return 1;
> +    }
> +
>      return CreateIRichEditOle(editor, ppvObj);
>    }
>    case EM_GETPASSWORDCHAR:


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

You release the final ref in the editor destructor.

> diff --git a/dlls/riched20/editstr.h b/dlls/riched20/editstr.h
> index f139c29..3722c82 100644
> --- a/dlls/riched20/editstr.h
> +++ b/dlls/riched20/editstr.h
> @@ -388,6 +388,7 @@ typedef struct tagME_TextEditor
>  {
>    HWND hWnd, hwndParent;
>    ITextHost *texthost;
> +  LPVOID reOle;

Needs correct type.

Huw.



More information about the wine-devel mailing list