[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ms-atl
Subject:    Pbm with Synchronous Notifications
From:       Glassbox <Glassbox () WANADOO ! FR>
Date:       1997-10-29 21:31:41
[Download RAW message or body]


I have ObjectA and ObjectB which are two simple COM objects implemented with ATL.
ObjectA implements connection points for the IObjectB interface
(and is able to fire events without using the Proxy Generator)

All is working in a single process, without asynchronous notification.
ObjectA fires an event to ObjectB.
During the call to this event, the ObjectB advises to the ObjectA.

What becomes the CComDynamicUnkArray of ObjectA.?

The CComDynamicUnkArray of ObjectA is not correctly updated when ObjectB
subscribes, and ObjectA tries to fire an event with an incorrect pointer.
The problem is the same if a third ObjectC subscribes to ObjectA during the Event call.

Extract of the implementation:
STDMETHODIMP CObjectA::Fire()
{
   HRESULT hr;
   IConnectionPointImpl<CObjectA, &IID_IObjectB, CComDynamicUnkArray>*p=this;
   IUnknown** pp = p->m_vec.begin();
   while (pp < p->m_vec.end())
   {
        if (*pp != NULL)
        {
                IObjectB *pIObjectB = (IObjectB *)*pp;
                hr = pIObjectB->Event();
        }
        pp++;
   }
   return S_OK;
}
STDMETHODIMP CObjectB::Event()
{
        DWORD dwCookie = 0;
        HRESULT hr = AtlAdvise(m_pMyObjectA, GetUnknown(), IID_IObjectB, &dwCookie)
        return S_OK;
}
m_pMyObjectA is a pointer to the ObjectA gives at initialization .

Thank you  for help,

Aline

----------------------------------------------------------------
Users Guide http://www.microsoft.com/sitebuilder/resource/mailfaq.asp
contains important info including how to unsubscribe.  Save time, search
the archives at http://microsoft.ease.lsoft.com/archives/index.html

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic