Skip to content

Commit

Permalink
Added a few comments and fixed a bug
Browse files Browse the repository at this point in the history
(the application crashed when a puts was done in a child thread)
  • Loading branch information
vincentisambart committed Nov 15, 2008
1 parent eb72b74 commit 8b96794
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# TODO:
# - stdin
# - do not perform_action if the code is not finished (needs a simple lexer)
# - split in multiple files

class Object
# calls a method on the object on the main thread
Expand Down Expand Up @@ -52,6 +53,9 @@ def puts(str)

private

# The core of write/puts: tries to find the target where to
# write the text and calls the indicated function on it
# It returns the number of characters in the given string
def find_target_and_call(function_name, str)
current_thread = Thread.current
target = current_thread[:_irb_stdout_target]
Expand Down Expand Up @@ -170,9 +174,7 @@ def start
@history = [ ]
@pos_in_history = 0

terminal = self

@eval_thread = EvalThread.start(terminal)
@eval_thread = EvalThread.start(self)

frame = [300, 300, 600, 400]
w = NSApp.mainWindow
Expand All @@ -183,7 +185,6 @@ def start
HotCocoa.window :frame => frame, :title => "MacIrb" do |win|
@win = win
win.will_close { @eval_thread.end_thread }
win.delegate = self
win.contentView.margin = 0
@web_view = web_view(:layout => {:expand => [:width, :height]})
clear
Expand Down

0 comments on commit 8b96794

Please sign in to comment.