Skip to content

Commit 0c5e6ab

Browse files
author
suke
committed
* 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
1 parent 1588a79 commit 0c5e6ab

File tree

2 files changed

+40
-27
lines changed

2 files changed

+40
-27
lines changed

ChangeLog

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
Sat Sep 1 19:59:43 2007 Masaki Suketa <masaki.suketa@nifty.ne.jp>
2+
3+
* ext/win32ole/win32ole.c (ole_event_free): IConnectionPoint should be
4+
released.
5+
6+
* ext/win32ole/win32ole.c (EVENTSINK_Destructor): ITypeInfo should be
7+
released.
8+
9+
* ext/win32ole/win32ole.c (fev_initialize): refactoring.
10+
111
Sat Sep 1 16:26:09 2007 NAKAMURA Usaku <usa@ruby-lang.org>
212

313
* test/socket/test_tcp.rb (test_recvfrom): same as mswin32 on mswin64.

ext/win32ole/win32ole.c

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116

117117
#define WC2VSTR(x) ole_wc2vstr((x), TRUE)
118118

119-
#define WIN32OLE_VERSION "1.0.7"
119+
#define WIN32OLE_VERSION "1.0.8"
120120

121121
typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX)
122122
(REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*);
@@ -170,8 +170,6 @@ typedef struct tagIEVENTSINKOBJ {
170170
DWORD m_cRef;
171171
IID m_iid;
172172
int m_event_id;
173-
DWORD m_dwCookie;
174-
IConnectionPoint *pConnectionPoint;
175173
ITypeInfo *pTypeInfo;
176174
}IEVENTSINKOBJ, *PIEVENTSINKOBJ;
177175

@@ -229,7 +227,8 @@ struct oleparamdata {
229227
};
230228

231229
struct oleeventdata {
232-
int freed;
230+
DWORD dwCookie;
231+
IConnectionPoint *pConnectionPoint;
233232
};
234233

235234
struct oleparam {
@@ -488,6 +487,7 @@ static HRESULT find_iid(VALUE ole, char *pitf, IID *piid, ITypeInfo **ppTypeInfo
488487
static HRESULT find_default_source(VALUE ole, IID *piid, ITypeInfo **ppTypeInfo);
489488
static void ole_event_free(struct oleeventdata *poleev);
490489
static VALUE fev_s_allocate(VALUE klass);
490+
static VALUE ev_advise(int argc, VALUE *argv, VALUE self);
491491
static VALUE fev_initialize(int argc, VALUE *argv, VALUE self);
492492
static VALUE fev_s_msg_loop(VALUE klass);
493493
static void add_event_call_back(VALUE obj, VALUE event, VALUE data);
@@ -7138,8 +7138,6 @@ EVENTSINK_Constructor() {
71387138
pEv->lpVtbl = &vtEventSink;
71397139
pEv->m_cRef = 0;
71407140
pEv->m_event_id = 0;
7141-
pEv->m_dwCookie = 0;
7142-
pEv->pConnectionPoint = NULL;
71437141
pEv->pTypeInfo = NULL;
71447142
return pEv;
71457143
}
@@ -7148,6 +7146,7 @@ void EVENTSINK_Destructor(
71487146
PIEVENTSINKOBJ pEVObj
71497147
) {
71507148
if(pEVObj != NULL) {
7149+
OLE_RELEASE(pEVObj->pTypeInfo);
71517150
free(pEVObj);
71527151
pEVObj = NULL;
71537152
}
@@ -7359,8 +7358,7 @@ find_default_source(VALUE ole, IID *piid, ITypeInfo **ppTypeInfo)
73597358
static void
73607359
ole_event_free(struct oleeventdata *poleev)
73617360
{
7362-
ITypeInfo *pti = NULL;
7363-
IConnectionPoint *pcp = NULL;
7361+
OLE_FREE(poleev->pConnectionPoint);
73647362
free(poleev);
73657363
}
73667364

@@ -7370,25 +7368,15 @@ fev_s_allocate(VALUE klass)
73707368
VALUE obj;
73717369
struct oleeventdata *poleev;
73727370
obj = Data_Make_Struct(klass,struct oleeventdata,0,ole_event_free,poleev);
7373-
/*
7374-
poleev->pEvent = NULL;
7375-
*/
7371+
poleev->dwCookie = 0;
7372+
poleev->pConnectionPoint = NULL;
73767373
return obj;
73777374
}
73787375

7379-
/*
7380-
* call-seq:
7381-
* WIN32OLE_EVENT.new(ole, event) #=> WIN32OLE_EVENT object.
7382-
*
7383-
* Returns OLE event object.
7384-
* The first argument specifies WIN32OLE object.
7385-
* The second argument specifies OLE event name.
7386-
* ie = WIN32OLE.new('InternetExplorer.Application')
7387-
* ev = WIN32OLE_EVENT.new(ie, 'DWebBrowserEvents')
7388-
*/
73897376
static VALUE
7390-
fev_initialize(int argc, VALUE *argv, VALUE self)
7377+
ev_advise(int argc, VALUE *argv, VALUE self)
73917378
{
7379+
73927380
VALUE ole, itf;
73937381
struct oledata *pole;
73947382
char *pitf;
@@ -7457,14 +7445,29 @@ fev_initialize(int argc, VALUE *argv, VALUE self)
74577445
Data_Get_Struct(self, struct oleeventdata, poleev);
74587446
pIEV->m_event_id
74597447
= NUM2INT(rb_funcall(ary_ole_event, rb_intern("length"), 0));
7460-
pIEV->pConnectionPoint = pConnectionPoint;
74617448
pIEV->pTypeInfo = pTypeInfo;
7462-
pIEV->m_dwCookie = dwCookie;
7449+
poleev->dwCookie = dwCookie;
7450+
poleev->pConnectionPoint = pConnectionPoint;
74637451

7464-
rb_ary_push(ary_ole_event, self);
7452+
return self;
7453+
}
74657454

7466-
events = rb_ary_new();
7467-
rb_ivar_set(self, id_events, events);
7455+
/*
7456+
* call-seq:
7457+
* WIN32OLE_EVENT.new(ole, event) #=> WIN32OLE_EVENT object.
7458+
*
7459+
* Returns OLE event object.
7460+
* The first argument specifies WIN32OLE object.
7461+
* The second argument specifies OLE event name.
7462+
* ie = WIN32OLE.new('InternetExplorer.Application')
7463+
* ev = WIN32OLE_EVENT.new(ie, 'DWebBrowserEvents')
7464+
*/
7465+
static VALUE
7466+
fev_initialize(int argc, VALUE *argv, VALUE self)
7467+
{
7468+
ev_advise(argc, argv, self);
7469+
rb_ary_push(ary_ole_event, self);
7470+
rb_ivar_set(self, id_events, rb_ary_new());
74687471
return self;
74697472
}
74707473

0 commit comments

Comments
 (0)