Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ActiveX/COM Problem

Posted on 1998-03-18
3
Medium Priority
?
341 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 600 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

704 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