Solved

ActiveX/COM Problem

Posted on 1998-03-18
3
333 Views
Last Modified: 2013-11-19
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?
0
Comment
Question by:richp
  • 2
3 Comments
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1317056
When you do a QueryInterface(), which interface do you release?
0
 

Author Comment

by:richp
ID: 1317057
     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;

0
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 300 total points
ID: 1317058
I think there's a problem in this code:

  m_pVolSurf = GetETSControl(lpUnk, &lpContext);
  lpContext->Release();

You are calling GetETSControl() to retrieve the IID_IMarketSet_SnapIn interface. However, as soon as the GetETSControl function returns, you are release the interface that was returned. The code should be

  m_pVolSurf = GetETSControl(lpUnk, &lpContext);
  lpUnk->Release();  // << new stuff here
  lpUnk = NULL; // << new stuff here

I think this is what you want.


0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question