mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
win32ole.rb: use TracePoint
* 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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2d59c39978
commit
0c61c3b67b
3 changed files with 27 additions and 23 deletions
|
@ -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>
|
Wed Jan 16 09:35:53 2013 Eric Hodel <drbrain@segment7.net>
|
||||||
|
|
||||||
* .document: Removed extra space
|
* .document: Removed extra space
|
||||||
|
|
|
@ -3,20 +3,5 @@ require 'win32ole.so'
|
||||||
# re-define Thread#initialize
|
# re-define Thread#initialize
|
||||||
# bug #2618(ruby-core:27634)
|
# bug #2618(ruby-core:27634)
|
||||||
|
|
||||||
class Thread
|
TracePoint.trace(:thread_begin) {WIN32OLE.ole_initialize}
|
||||||
alias :org_initialize :initialize
|
TracePoint.trace(:thread_end) {WIN32OLE.ole_uninitialize}
|
||||||
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
|
|
||||||
|
|
|
@ -9,12 +9,25 @@ if defined?(WIN32OLE)
|
||||||
#
|
#
|
||||||
# test for Bug #2618(ruby-core:27634)
|
# test for Bug #2618(ruby-core:27634)
|
||||||
#
|
#
|
||||||
def test_creating_win32ole_object_in_thread
|
def assert_creating_win32ole_object_in_thread(meth)
|
||||||
t = Thread.new do
|
t = Thread.__send__(meth) {
|
||||||
dict = WIN32OLE.new('Scripting.Dictionary')
|
WIN32OLE.new('Scripting.Dictionary')
|
||||||
assert(true)
|
}
|
||||||
end
|
assert_nothing_raised(WIN32OLERuntimeError, "[Bug #2618] Thread.#{meth}") {
|
||||||
t.join
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue