* ext/win32ole/win32ole.c (ole_event_free): IConnectionPoint should be

released.

* ext/win32ole/win32ole.c (EVENTSINK_Destructor): ITypeInfo should be
  released.

* ext/win32ole/win32ole.c (fev_initialize): refactoring.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
suke 2007-09-01 11:11:51 +00:00
parent 1588a79069
commit 0c5e6ab2bb
2 changed files with 40 additions and 27 deletions

View File

@ -1,3 +1,13 @@
Sat Sep 1 19:59:43 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c (ole_event_free): IConnectionPoint should be
released.
* ext/win32ole/win32ole.c (EVENTSINK_Destructor): ITypeInfo should be
released.
* ext/win32ole/win32ole.c (fev_initialize): refactoring.
Sat Sep 1 16:26:09 2007 NAKAMURA Usaku <usa@ruby-lang.org> Sat Sep 1 16:26:09 2007 NAKAMURA Usaku <usa@ruby-lang.org>
* test/socket/test_tcp.rb (test_recvfrom): same as mswin32 on mswin64. * test/socket/test_tcp.rb (test_recvfrom): same as mswin32 on mswin64.

View File

@ -116,7 +116,7 @@
#define WC2VSTR(x) ole_wc2vstr((x), TRUE) #define WC2VSTR(x) ole_wc2vstr((x), TRUE)
#define WIN32OLE_VERSION "1.0.7" #define WIN32OLE_VERSION "1.0.8"
typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX) typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX)
(REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*); (REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*);
@ -170,8 +170,6 @@ typedef struct tagIEVENTSINKOBJ {
DWORD m_cRef; DWORD m_cRef;
IID m_iid; IID m_iid;
int m_event_id; int m_event_id;
DWORD m_dwCookie;
IConnectionPoint *pConnectionPoint;
ITypeInfo *pTypeInfo; ITypeInfo *pTypeInfo;
}IEVENTSINKOBJ, *PIEVENTSINKOBJ; }IEVENTSINKOBJ, *PIEVENTSINKOBJ;
@ -229,7 +227,8 @@ struct oleparamdata {
}; };
struct oleeventdata { struct oleeventdata {
int freed; DWORD dwCookie;
IConnectionPoint *pConnectionPoint;
}; };
struct oleparam { struct oleparam {
@ -488,6 +487,7 @@ static HRESULT find_iid(VALUE ole, char *pitf, IID *piid, ITypeInfo **ppTypeInfo
static HRESULT find_default_source(VALUE ole, IID *piid, ITypeInfo **ppTypeInfo); static HRESULT find_default_source(VALUE ole, IID *piid, ITypeInfo **ppTypeInfo);
static void ole_event_free(struct oleeventdata *poleev); static void ole_event_free(struct oleeventdata *poleev);
static VALUE fev_s_allocate(VALUE klass); static VALUE fev_s_allocate(VALUE klass);
static VALUE ev_advise(int argc, VALUE *argv, VALUE self);
static VALUE fev_initialize(int argc, VALUE *argv, VALUE self); static VALUE fev_initialize(int argc, VALUE *argv, VALUE self);
static VALUE fev_s_msg_loop(VALUE klass); static VALUE fev_s_msg_loop(VALUE klass);
static void add_event_call_back(VALUE obj, VALUE event, VALUE data); static void add_event_call_back(VALUE obj, VALUE event, VALUE data);
@ -7138,8 +7138,6 @@ EVENTSINK_Constructor() {
pEv->lpVtbl = &vtEventSink; pEv->lpVtbl = &vtEventSink;
pEv->m_cRef = 0; pEv->m_cRef = 0;
pEv->m_event_id = 0; pEv->m_event_id = 0;
pEv->m_dwCookie = 0;
pEv->pConnectionPoint = NULL;
pEv->pTypeInfo = NULL; pEv->pTypeInfo = NULL;
return pEv; return pEv;
} }
@ -7148,6 +7146,7 @@ void EVENTSINK_Destructor(
PIEVENTSINKOBJ pEVObj PIEVENTSINKOBJ pEVObj
) { ) {
if(pEVObj != NULL) { if(pEVObj != NULL) {
OLE_RELEASE(pEVObj->pTypeInfo);
free(pEVObj); free(pEVObj);
pEVObj = NULL; pEVObj = NULL;
} }
@ -7359,8 +7358,7 @@ find_default_source(VALUE ole, IID *piid, ITypeInfo **ppTypeInfo)
static void static void
ole_event_free(struct oleeventdata *poleev) ole_event_free(struct oleeventdata *poleev)
{ {
ITypeInfo *pti = NULL; OLE_FREE(poleev->pConnectionPoint);
IConnectionPoint *pcp = NULL;
free(poleev); free(poleev);
} }
@ -7370,25 +7368,15 @@ fev_s_allocate(VALUE klass)
VALUE obj; VALUE obj;
struct oleeventdata *poleev; struct oleeventdata *poleev;
obj = Data_Make_Struct(klass,struct oleeventdata,0,ole_event_free,poleev); obj = Data_Make_Struct(klass,struct oleeventdata,0,ole_event_free,poleev);
/* poleev->dwCookie = 0;
poleev->pEvent = NULL; poleev->pConnectionPoint = NULL;
*/
return obj; return obj;
} }
/*
* call-seq:
* WIN32OLE_EVENT.new(ole, event) #=> WIN32OLE_EVENT object.
*
* Returns OLE event object.
* The first argument specifies WIN32OLE object.
* The second argument specifies OLE event name.
* ie = WIN32OLE.new('InternetExplorer.Application')
* ev = WIN32OLE_EVENT.new(ie, 'DWebBrowserEvents')
*/
static VALUE static VALUE
fev_initialize(int argc, VALUE *argv, VALUE self) ev_advise(int argc, VALUE *argv, VALUE self)
{ {
VALUE ole, itf; VALUE ole, itf;
struct oledata *pole; struct oledata *pole;
char *pitf; char *pitf;
@ -7457,14 +7445,29 @@ fev_initialize(int argc, VALUE *argv, VALUE self)
Data_Get_Struct(self, struct oleeventdata, poleev); Data_Get_Struct(self, struct oleeventdata, poleev);
pIEV->m_event_id pIEV->m_event_id
= NUM2INT(rb_funcall(ary_ole_event, rb_intern("length"), 0)); = NUM2INT(rb_funcall(ary_ole_event, rb_intern("length"), 0));
pIEV->pConnectionPoint = pConnectionPoint;
pIEV->pTypeInfo = pTypeInfo; pIEV->pTypeInfo = pTypeInfo;
pIEV->m_dwCookie = dwCookie; poleev->dwCookie = dwCookie;
poleev->pConnectionPoint = pConnectionPoint;
return self;
}
/*
* call-seq:
* WIN32OLE_EVENT.new(ole, event) #=> WIN32OLE_EVENT object.
*
* Returns OLE event object.
* The first argument specifies WIN32OLE object.
* The second argument specifies OLE event name.
* ie = WIN32OLE.new('InternetExplorer.Application')
* ev = WIN32OLE_EVENT.new(ie, 'DWebBrowserEvents')
*/
static VALUE
fev_initialize(int argc, VALUE *argv, VALUE self)
{
ev_advise(argc, argv, self);
rb_ary_push(ary_ole_event, self); rb_ary_push(ary_ole_event, self);
rb_ivar_set(self, id_events, rb_ary_new());
events = rb_ary_new();
rb_ivar_set(self, id_events, events);
return self; return self;
} }