On Thu, Sep 11, 2014 at 05:35:38PM +0800, Jactry Zeng wrote:
+static HRESULT CreateITextRange(IRichEditOleImpl *reOle, LONG start, LONG end,
ITextRangeImpl *txtRge, ITextRange** ppRange)
+{
- txtRge->ITextRange_iface.lpVtbl = &trvt;
- txtRge->ref = 1;
- txtRge->reOle = reOle;
- txtRge->start = start;
- txtRge->end = end;
- list_add_head(&reOle->rangelist, &txtRge->entry);
- *ppRange = &txtRge->ITextRange_iface;
- return S_OK;
+}
This looks very suspicious to me. You're storing a reference to 'reOle' so you should AddRef it somewhere. It may be better to pass the interface ptr, AddRef and store that.
Also, is the purpose of rangelist just to be able to NULL out reOle when the parent object is destroyed? If so, this can go away if you correctly handle the ref counting.
Huw.