summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-09-16 14:14:56 +0000
committersuke <suke@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-09-16 14:14:56 +0000
commitb1d1b1b1d35b129da06e54cc98972d6e25d4a0ba (patch)
tree9553d2e4957a14f37327168b53b24509b7ea3c8e
parent6291abe61e8a363ad176ff1324f57f9915b48108 (diff)
fix bug in ext/win32ole/sample/ienavi.rb
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9186 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--ext/win32ole/tests/testOLEEVENT.rb18
-rw-r--r--ext/win32ole/win32ole.c8
3 files changed, 30 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 46e3c2e..b23bf22 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Fri Sep 16 23:09:20 2005 Masaki Suketa <masaki.suketa@nifty.ne.jp>
+
+ * ext/win32ole/win32ole.c (ole_search_event_at): bug fix
+ in ext/win32ole/sample/ienavi.rb.
+
+ * ext/win32ole/win32ole/tests/testOLEEVENT.rb: ditto.
+
Fri Sep 16 22:41:18 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* file.c (rb_file_s_extname): empty string for path name ending with a
diff --git a/ext/win32ole/tests/testOLEEVENT.rb b/ext/win32ole/tests/testOLEEVENT.rb
index 368794b..0901158 100644
--- a/ext/win32ole/tests/testOLEEVENT.rb
+++ b/ext/win32ole/tests/testOLEEVENT.rb
@@ -6,6 +6,7 @@ class TestWIN32OLE_EVENT < RUNIT::TestCase
@excel = WIN32OLE.new("Excel.Application")
@excel.visible = true
@event = ""
+ @event2 = ""
end
def test_on_event
book = @excel.workbooks.Add
@@ -33,6 +34,10 @@ class TestWIN32OLE_EVENT < RUNIT::TestCase
@event += "handler2"
end
+ def handler3
+ @event += "handler3"
+ end
+
def test_on_event2
book = @excel.workbooks.Add
begin
@@ -63,6 +68,19 @@ class TestWIN32OLE_EVENT < RUNIT::TestCase
assert_equal("handler2", @event)
end
+ def test_on_event4
+ book = @excel.workbooks.Add
+ begin
+ ev = WIN32OLE_EVENT.new(book, 'WorkbookEvents')
+ ev.on_event{ handler1 }
+ ev.on_event{ handler2 }
+ ev.on_event('SheetChange'){|arg1, arg2| handler3 }
+ book.Worksheets(1).Range("A1").value = "OK"
+ ensure
+ book.saved = true
+ end
+ assert_equal("handler3", @event)
+ end
def teardown
@excel.quit
diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c
index 5658018..a463d3c 100644
--- a/ext/win32ole/win32ole.c
+++ b/ext/win32ole/win32ole.c
@@ -78,7 +78,7 @@
#define WC2VSTR(x) ole_wc2vstr((x), TRUE)
-#define WIN32OLE_VERSION "0.6.3"
+#define WIN32OLE_VERSION "0.6.4"
typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX)
(REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*);
@@ -4878,7 +4878,9 @@ ole_search_event_at(ary, ev)
ret = i;
break;
}
- else if (rb_str_cmp(ev, event_name) == 0) {
+ else if (TYPE(ev) == T_STRING &&
+ TYPE(event_name) == T_STRING &&
+ rb_str_cmp(ev, event_name) == 0) {
ret = i;
break;
}
@@ -5453,7 +5455,7 @@ add_event_call_back(obj, event, data)
rb_ivar_set(obj, id_events, events);
}
at = ole_search_event_at(events, event);
- if (at >= -1) {
+ if (at > -1) {
rb_ary_delete_at(events, at);
}
rb_ary_push(events, data);