Skip to content

Commit

Permalink
Added ReentryHelpers to help stop Window:closed event being thrown mu…
Browse files Browse the repository at this point in the history
…ltiple times
  • Loading branch information
danlucraft committed Feb 17, 2010
1 parent 1cf52ee commit e09ac1e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
4 changes: 3 additions & 1 deletion plugins/application/lib/application/window.rb
Expand Up @@ -178,7 +178,9 @@ def close
if notebooks.length > 1
close_notebook
end
notify_listeners(:closed, self)
ignore(:closing) do
notify_listeners(:closed, self)
end
end

def inspect
Expand Down
12 changes: 2 additions & 10 deletions plugins/application_swt/lib/application_swt/speedbar.rb
@@ -1,6 +1,8 @@
module Redcar
class ApplicationSWT
class Speedbar
include Redcar::ReentryHelpers

attr_reader :widget

def initialize(window, parent, model)
Expand Down Expand Up @@ -51,16 +53,6 @@ def focussable_widgets
@focussable_widgets ||= []
end

def ignore_changes
@ignore_changes ||= Hash.new(0)
end

def ignore(name)
ignore_changes[name] += 1
yield if ignore_changes[name] == 1
ignore_changes[name] -= 1
end

def create_widgets
create_bar_widget
create_item_widgets
Expand Down
1 change: 1 addition & 0 deletions plugins/core/lib/core.rb
Expand Up @@ -3,6 +3,7 @@
require 'fileutils'

require "core/logger"
require "core/reentry_helpers"
require "core/controller"
require "core/gui"
require "core/interface"
Expand Down
2 changes: 2 additions & 0 deletions plugins/core/lib/core/model.rb
@@ -1,5 +1,7 @@
module Redcar
module Model
include Redcar::ReentryHelpers

attr_reader :controller

def controller=(controller)
Expand Down
13 changes: 13 additions & 0 deletions plugins/core/lib/core/reentry_helpers.rb
@@ -0,0 +1,13 @@
module Redcar
module ReentryHelpers
def ignore_changes
@ignore_changes ||= Hash.new(0)
end

def ignore(name)
ignore_changes[name] += 1
yield if ignore_changes[name] == 1
ignore_changes[name] -= 1
end
end
end

0 comments on commit e09ac1e

Please sign in to comment.