Solved

ActiveX/COM Problem

Posted on 1998-03-18
3
329 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now