diff --git a/docs/ReleaseNotes.html b/docs/ReleaseNotes.html
index a909f40..054b85b 100644
--- a/docs/ReleaseNotes.html
+++ b/docs/ReleaseNotes.html
@@ -15,6 +15,10 @@
| Bugs |
+
+ | 3412922 |
+ (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. |
+
| |
|
diff --git a/jni/DispatchEvents.cpp b/jni/DispatchEvents.cpp
index 082a041..71a063b 100644
--- a/jni/DispatchEvents.cpp
+++ b/jni/DispatchEvents.cpp
@@ -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);
diff --git a/jni/EventProxy.cpp b/jni/EventProxy.cpp
index 496e8fc..7c035b6 100644
--- a/jni/EventProxy.cpp
+++ b/jni/EventProxy.cpp
@@ -100,6 +100,8 @@ EventProxy::~EventProxy()
void EventProxy::Disconnect() {
if (connected) {
+ // insure we don't call Unadvise twice
+ connected = 0;
pCP->Unadvise(dwEventCookie);
}
}
diff --git a/jni/EventProxy.h b/jni/EventProxy.h
index e0c79ac..fb02ed3 100644
--- a/jni/EventProxy.h
+++ b/jni/EventProxy.h
@@ -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();
+
};