Page 1 of 1

multiple instances of activeX in MFC

Posted: 22 Jan 2008 12:47
by knight730
Hi,

I have set mulitiple instances in my MFC application. It's normarl while beginning,but when I made them quit ,the app crash!!!!

who knows?
//create vlc

Code: Select all

for (int i=0;i<vlcCount;i++) { memset(temp,0,sizeof(temp)); sprintf_s(temp,10,"%d",(i+1)); vlc[i] = NULL; vlc[i] = new CVlcplugin1; //position CRect rect; GetClientRect(&rect); rect.SetRect(cx,cy,cx+190,cy+190); cx+=200; if (cx==1400) { cy+=200; cx=0; } vlc[i]->Create(temp,WS_CHILD | WS_VISIBLE ,rect,this,IDC_VLCPLUGIN1); VARIANT va; VariantInit(&va); vlc[i]->addTarget ("c:\\test.avi", va, 1,0); vlc[i]->put_Visible(TRUE); vlc[i]->put_Volume(50); } //play for (int i=0;i<vlcCount;i++) { vlc[i]->play(); }
//release vlc

Code: Select all

for (int i=0;i<count;i++) { if (vlc[i]!=NULL) { if (vlc[i]->get_Playing()) { vlc[i]->stop(); vlc[i]->DestroyWindow(); delete vlc[i]; vlc[i]=NULL; } } }
thanks you!
cheers
maojz

Re: multiple instances of activeX in MFC

Posted: 22 Jan 2008 17:45
by Jean-Baptiste Kempf
Give us backtrace and FIX vlc!

Re: multiple instances of activeX in MFC

Posted: 23 Jan 2008 04:04
by knight730
thank you j-b
Ok,I will describe the problem with more specifiction.

when I set more than two vlc in my MFC application,In the release vlc fuction,in the second "for cycle",at vlc->destroywindow(); the app will crash.and jump this window: Monitors.exe at 0x7c92eb74 exception: 0xC0000008: An invalid handle was specified.

and the code will jump into occsite.cpp ,at m_pObject->Release();:

Code: Select all

COleControlSite::COleControlSite(COleControlContainer* pCtrlCont) : m_pCtrlCont(pCtrlCont), m_pWndCtrl(NULL), m_pDC(NULL), m_nID((UINT)-1), m_pObject(NULL), m_pInPlaceObject(NULL), m_pActiveObject(NULL), m_pWindowlessObject(NULL), m_dwEventSink(0), m_dwPropNotifySink(0), m_dwMiscStatus(0), m_dwNotifyDBEvents(0), m_pDataSourceControl(NULL), m_pDSCSite(NULL), m_defdispid(0), m_dwType(0), m_pBindings(NULL), m_bIgnoreNotify(FALSE), m_bIsDirty(FALSE), m_bIsWindowless(FALSE) { memset(&m_varResult, 0, sizeof(VARIANT)); m_varResult.vt = VT_EMPTY; } COleControlSite::~COleControlSite() { if (m_pCtrlCont && m_pCtrlCont->m_pSiteCapture == this) { m_pCtrlCont->m_pSiteCapture = NULL; } delete m_pDataSourceControl; DetachWindow(); DisconnectSink(m_iidEvents, m_dwEventSink); DisconnectSink(IID_IPropertyNotifySink, m_dwPropNotifySink); DisconnectSink(IID_INotifyDBEvents, m_dwNotifyDBEvents); if (m_pWindowlessObject != NULL) { m_pWindowlessObject->Release(); m_pWindowlessObject = NULL; } if (m_pInPlaceObject != NULL) { m_pInPlaceObject->InPlaceDeactivate(); m_pInPlaceObject->Release(); m_pInPlaceObject = NULL; } if (m_pActiveObject != NULL) { m_pActiveObject->Release(); m_pActiveObject = NULL; } if (m_pObject != NULL) { m_pObject->SetClientSite(NULL); m_pObject->Close(OLECLOSE_NOSAVE); m_pObject->Release(); m_pObject = NULL; } ::VariantClear(&m_varResult); BindProperty(DISPID_UNKNOWN, NULL); // gets rid of complex bindings if (m_defdispid != 0 && m_pDSCSite != NULL && m_pDSCSite->m_pDataSourceControl != NULL) { // get rid of simple bindings m_pDSCSite->m_pDataSourceControl->BindProp(this, FALSE); } if (m_pCtrlCont && m_bIsWindowless) { m_pCtrlCont->m_nWindowlessControls--; ASSERT(m_pCtrlCont->m_nWindowlessControls >= 0); } }

Any question with the release fuction that I have writed?


thank you !
Best Regards,
maojz

Re: multiple instances of activeX in MFC

Posted: 23 Jan 2008 04:04
by knight730
I used vlc :0.8.6d

Re: multiple instances of activeX in MFC

Posted: 24 Jan 2008 02:50
by knight730
Anybody knows about it???
It seems a bug for VLC.

maojz

Re: multiple instances of activeX in MFC

Posted: 05 Feb 2008 16:35
by benjis
Hi

Send me the project and will look into it to: spitzerbenjamin@gmail.com

Benji