15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


COleVariant and LPDISPATCH

Ted -- tward@geographix.com
Tuesday, April 23, 1996


Can someone explain why this happens:

I am calling an inproc OLE Automation dll from within an OCX and I am   
passing it an LPDISPATCH which is contained in an COleVariant.  I am   
doing nothing with the dispatch pointer in the dll, simply returning.  I   
release the LPDISPATCH pointer in my OCX, and get a return of 0 from   
Release().  However when the COleVariant goes out of scope I get an   
access error.  However, if I first reset the COleVariant to   
(LPDISPATCH)NULL, everything is hunky dory.

It took me 2 days to figure out this damn problem, but I still don't know   
why it is happening.

NT 3.51, VC 4.1.


Ted Ward

tward@geographix.com
Denver, Colorado  



John & Annette Elsbree -- elsbree@msn.com
Monday, April 29, 1996

Ted -

Have a look at the MFC source code... COleVariant::~COleVariant calls the 
VariantClear API. VariantClear releases the IDispatch pointer, provided the 
pointer is non-NULL and the variant's type is VT_DISPATCH.

So, you're causing the IDispatch pointer to be released too many times.

Perhaps the easiest fix is to just avoid releasing the pointer yourself, and 
letting the destructor do the work for you.

John (not speaking for Microsoft)

----------
From: 	owner-mfc-l@netcom.com on behalf of Ward, Ted

I am calling an inproc OLE Automation dll from within an OCX and I am   
passing it an LPDISPATCH which is contained in an COleVariant.  I am   
doing nothing with the dispatch pointer in the dll, simply returning.  I   
release the LPDISPATCH pointer in my OCX, and get a return of 0 from   
Release().  However when the COleVariant goes out of scope I get an   
access error.  However, if I first reset the COleVariant to   
(LPDISPATCH)NULL, everything is hunky dory.



Ted -- tward@geographix.com
Tuesday, April 30, 1996


But I tried just not releasing, and I was getting memory leaks.  If I set   
the COleVariant to VT_NULL, and release the dispatch myself, I get no   
leaks.

Ted Ward

tward@geographix.com
Denver, Colorado

 ----------
From:  mfc-l[SMTP:mfc-l@netcom.com]
Sent:  Tuesday, April 30, 1996 9:07 AM
To:  MFC List
Subject:  RE: COleVariant and LPDISPATCH

Ted -

Have a look at the MFC source code... COleVariant::~COleVariant calls the   

VariantClear API. VariantClear releases the IDispatch pointer, provided   
the
pointer is non-NULL and the variant's type is VT_DISPATCH.

So, you're causing the IDispatch pointer to be released too many times.

Perhaps the easiest fix is to just avoid releasing the pointer yourself,   
and
letting the destructor do the work for you.

John (not speaking for Microsoft)

 ----------
From:  owner-mfc-l@netcom.com on behalf of Ward, Ted

I am calling an inproc OLE Automation dll from within an OCX and I am
passing it an LPDISPATCH which is contained in an COleVariant.  I am
doing nothing with the dispatch pointer in the dll, simply returning.  I   
    

release the LPDISPATCH pointer in my OCX, and get a return of 0 from
Release().  However when the COleVariant goes out of scope I get an
access error.  However, if I first reset the COleVariant to
(LPDISPATCH)NULL, everything is hunky dory.




Phillip Thoren -- pthoren@synervision.com
Thursday, May 02, 1996

I have a tool called VisionSoft/CHECK, CHECK++ than may find this particular 
problem!

regards,

VisionSoft - http://www.synervision.com
---Message from "Ward, Ted"  on Tue, 30 Apr 1996 10:26:00 
-0600 ---

But I tried just not releasing, and I was getting memory leaks.  If I set   
the COleVariant to VT_NULL, and release the dispatch myself, I get no   
leaks.

Ted Ward

tward@geographix.com
Denver, Colorado

 ----------
From:  mfc-l[SMTP:mfc-l@netcom.com]
Sent:  Tuesday, April 30, 1996 9:07 AM
To:  MFC List
Subject:  RE: COleVariant and LPDISPATCH

Ted -

Have a look at the MFC source code... COleVariant::~COleVariant calls the   

VariantClear API. VariantClear releases the IDispatch pointer, provided   
the
pointer is non-NULL and the variant's type is VT_DISPATCH.

So, you're causing the IDispatch pointer to be released too many times.

Perhaps the easiest fix is to just avoid releasing the pointer yourself,   
and
letting the destructor do the work for you.

John (not speaking for Microsoft)

 ----------
From:  owner-mfc-l@netcom.com on behalf of Ward, Ted

I am calling an inproc OLE Automation dll from within an OCX and I am
passing it an LPDISPATCH which is contained in an COleVariant.  I am
doing nothing with the dispatch pointer in the dll, simply returning.  I   
    

release the LPDISPATCH pointer in my OCX, and get a return of 0 from
Release().  However when the COleVariant goes out of scope I get an
access error.  However, if I first reset the COleVariant to
(LPDISPATCH)NULL, everything is hunky dory.



-----------------End of Original Message-----------------

-------------------------------------
Phil Thoren
VisionSoft Corporation, 1999 S Bascom Ave, Suite 700, Campbell, CA, USA, 95008-9872
pthoren@synervision.com (Phillip Thoren), http://www.synervision.com
5/2/96, 8:13:56 AM

"Software Quality, the Internet and Beyond"
TEST, CHECK/CHECK++, DataVision(tm), PERFORM, REMOTE, WebView(tm), WebTour(tm), 


Web sites of interest: www.wrs.com, www.webvalley.com
-------------------------------------





| Вернуться в корень Архива |