Skip to content

Commit

Permalink
3412922Fix for: When a DispatchEvent is created with a COM object, th…
Browse files Browse the repository at this point in the history
…e COM object is never released totally, and the destructor function is never called
  • Loading branch information
clay_shooter committed Oct 2, 2011
1 parent 8b39bdb commit b3d6de4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions jacob/docs/ReleaseNotes.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ <h3>Tracked Changes</h3>
<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>
Expand Down
3 changes: 3 additions & 0 deletions jacob/jni/DispatchEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions jacob/jni/EventProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ EventProxy::~EventProxy()

void EventProxy::Disconnect() {
if (connected) {
// insure we don't call Unadvise twice
connected = 0;
pCP->Unadvise(dwEventCookie);
}
}
Expand Down
4 changes: 3 additions & 1 deletion jacob/jni/EventProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class EventProxy : public IDispatch
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
Expand Down Expand Up @@ -98,4 +97,7 @@ class EventProxy : public IDispatch
// 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();

};

0 comments on commit b3d6de4

Please sign in to comment.