3412922Fix for: When a DispatchEvent is created with a COM object, the COM object is never released totally, and the destructor function is never called

This commit is contained in:
clay_shooter
2011-10-02 15:51:19 +00:00
parent 003671fb90
commit e5652e3b75
4 changed files with 12 additions and 1 deletions

View File

@@ -15,6 +15,10 @@
<tr>
<td colspan="2"><b>Bugs</b></td>
</tr>
<tr>
<td width="13%" valign="top">3412922</td>
<td width="87%" valign="top">(M1)Fix for: When a DispatchEvent is created with a COM object, the COM object is never released totally, and the destructor function is never called.</td>
</tr>
<tr>
<td width="13%" valign="top">&nbsp;</td>
<td width="87%" valign="top">&nbsp;</td>

View File

@@ -153,6 +153,9 @@ JNIEXPORT void JNICALL Java_com_jacob_com_DispatchEvents_release
{
EventProxy *ep = extractProxy(env, _this);
if (ep) {
// Disconnect must be called to reduce the ref count to the EventProxy otherwise
// the destructor will never be called (to actually do the disconnect)
ep->Disconnect(); // SF 3412922
// this is the line that blows up in IETest
ep->Release();
putProxy(env, _this, NULL);

View File

@@ -100,6 +100,8 @@ EventProxy::~EventProxy()
void EventProxy::Disconnect() {
if (connected) {
// insure we don't call Unadvise twice
connected = 0;
pCP->Unadvise(dwEventCookie);
}
}

View File

@@ -50,7 +50,6 @@ private:
JavaVM *jvm; // The java vm we are running
void convertJavaVariant(VARIANT *java, VARIANT *com);
void Connect(JNIEnv *env);
void Disconnect();
public:
// constuct with a global JNI ref to a sink object
// to which we will delegate event callbacks
@@ -98,4 +97,7 @@ public:
// These are the actual supported methods
STDMETHODIMP GetIDsOfNames(REFIID, OLECHAR **, UINT, LCID , DISPID *);
STDMETHODIMP Invoke(DISPID, REFIID, LCID, WORD , DISPPARAMS *, VARIANT *, EXCEPINFO *, UINT *);
// SF 3412922 make public to support cleanup from DispatchEvents
void Disconnect();
};