Link to home
Start Free TrialLog in
Avatar of richp
richp

asked on

ActiveX/COM Problem

I'm creating a chartfx component in a in proc com server:
      m_Chart.Create("ChartFx", WS_VISIBLE | WS_CHILD | WS_BORDER, aRect, this, IDR_CHART1);
      m_Chart.SetType(SCATTER | CT_TRACKMOUSE | CT_COLORLINE | CT_PAINTMARKER | CT_TOOL);
      m_Chart.SetWindowPos(0, 0, 0, aRect.Width(), aRect.Height(), SWP_NOMOVE | SWP_NOZORDER);

when I close the app, here's the call stack:
NTDLL! 77f76148()
NTDLL! 77f8a8b9()
NTDLL! 77f83209()
KERNEL32! 77f11ad0()
CFX32! 0277c496()
USER32! 77e71ab7()
USER32! 77e71a77()
NTDLL! 77f7624f()
CFX32! 02771c05()
COleDispatchDriver::~COleDispatchDriver() line 80 + 15 bytes
COleControlSite::~COleControlSite() line 99 + 33 bytes
COleControlSite::`scalar deleting destructor'(unsigned int 1) + 15 bytes
COleControlContainer::~COleControlContainer() line 120 + 31 bytes
COleControlContainer::`scalar deleting destructor'(unsigned int 1) + 15 bytes
CWnd::OnDestroy() line 764 + 34 bytes
CWnd::OnWndMsg(unsigned int 2, unsigned int 0, long 0, long * 0x0012f678) line 1815
CWnd::WindowProc(unsigned int 2, unsigned int 0, long 0) line 1575 + 30 bytes

When I QueryInterface I do a Release so the reference count should be 1.

I'm doing the same with formula1 and have no problems.  

Anyone know why the ReleaseDispatch() is being called before any of the destructor methods?
Avatar of Tommy Hui
Tommy Hui

When you do a QueryInterface(), which interface do you release?
Avatar of richp

ASKER

     m_pVolSurf = GetETSControl(lpUnk, &lpContext);
      lpContext->Release();
....
VolSurface * CVolatilityCtl::GetETSControl(      IUnknown* pUnk, ISnapInMarketSet** ppETSCtrl)
{
      _ASSERTE(pUnk);
      if (!pUnk || pUnk->QueryInterface(IID_IMarketSet_SnapIn, (LPVOID*) ppETSCtrl) != S_OK)
            return NULL;

ASKER CERTIFIED SOLUTION
Avatar of Tommy Hui
Tommy Hui

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial