summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--ext/win32ole/lib/win32ole.rb19
-rw-r--r--test/win32ole/test_thread.rb25
3 files changed, 27 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index f32ab5519c..a4a01dbf99 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Wed Jan 16 18:45:46 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * ext/win32ole/lib/win32ole.rb: use TracePoint to hook all thread
+ creation not only by Thread.new and to get rid of interference with
+ svar scope. [Bug #7681] [ruby-core:51365]
+
Wed Jan 16 09:35:53 2013 Eric Hodel <drbrain@segment7.net>
* .document: Removed extra space
diff --git a/ext/win32ole/lib/win32ole.rb b/ext/win32ole/lib/win32ole.rb
index aaf7e7cdcf..16c20120d2 100644
--- a/ext/win32ole/lib/win32ole.rb
+++ b/ext/win32ole/lib/win32ole.rb
@@ -3,20 +3,5 @@ require 'win32ole.so'
# re-define Thread#initialize
# bug #2618(ruby-core:27634)
-class Thread
- alias :org_initialize :initialize
- def initialize(*arg, &block)
- if block
- org_initialize(*arg) {
- WIN32OLE.ole_initialize
- begin
- block.call(*arg)
- ensure
- WIN32OLE.ole_uninitialize
- end
- }
- else
- org_initialize(*arg)
- end
- end
-end
+TracePoint.trace(:thread_begin) {WIN32OLE.ole_initialize}
+TracePoint.trace(:thread_end) {WIN32OLE.ole_uninitialize}
diff --git a/test/win32ole/test_thread.rb b/test/win32ole/test_thread.rb
index 947d85af9e..56a6357932 100644
--- a/test/win32ole/test_thread.rb
+++ b/test/win32ole/test_thread.rb
@@ -9,12 +9,25 @@ if defined?(WIN32OLE)
#
# test for Bug #2618(ruby-core:27634)
#
- def test_creating_win32ole_object_in_thread
- t = Thread.new do
- dict = WIN32OLE.new('Scripting.Dictionary')
- assert(true)
- end
- t.join
+ def assert_creating_win32ole_object_in_thread(meth)
+ t = Thread.__send__(meth) {
+ WIN32OLE.new('Scripting.Dictionary')
+ }
+ assert_nothing_raised(WIN32OLERuntimeError, "[Bug #2618] Thread.#{meth}") {
+ t.join
+ }
+ end
+
+ def test_creating_win32ole_object_in_thread_new
+ assert_creating_win32ole_object_in_thread(:new)
+ end
+
+ def test_creating_win32ole_object_in_thread_start
+ assert_creating_win32ole_object_in_thread(:start)
+ end
+
+ def test_creating_win32ole_object_in_thread_fork
+ assert_creating_win32ole_object_in_thread(:fork)
end
end
end