diff options
Diffstat (limited to 'ext/tk/lib/tkextlib/tcllib')
-rw-r--r-- | ext/tk/lib/tkextlib/tcllib/autoscroll.rb | 2 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/tcllib/ctext.rb | 2 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/tcllib/datefield.rb | 2 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/tcllib/ico.rb | 6 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/tcllib/ip_entry.rb | 2 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/tcllib/plotchart.rb | 77 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/tcllib/tkpiechart.rb | 14 |
7 files changed, 67 insertions, 38 deletions
diff --git a/ext/tk/lib/tkextlib/tcllib/autoscroll.rb b/ext/tk/lib/tkextlib/tcllib/autoscroll.rb index 6940a9174c..7db3c2e2b7 100644 --- a/ext/tk/lib/tkextlib/tcllib/autoscroll.rb +++ b/ext/tk/lib/tkextlib/tcllib/autoscroll.rb @@ -108,7 +108,7 @@ module Tk end end -class TkScrollbar +class Tk::Scrollbar def autoscroll # Arranges for the already existing scrollbar to be mapped # and unmapped as needed. diff --git a/ext/tk/lib/tkextlib/tcllib/ctext.rb b/ext/tk/lib/tkextlib/tcllib/ctext.rb index 70a45dd8e7..9014037f3d 100644 --- a/ext/tk/lib/tkextlib/tcllib/ctext.rb +++ b/ext/tk/lib/tkextlib/tcllib/ctext.rb @@ -15,7 +15,7 @@ TkPackage.require('ctext') module Tk module Tcllib - class CText < TkText + class CText < Tk::Text PACKAGE_NAME = 'ctext'.freeze def self.package_name PACKAGE_NAME diff --git a/ext/tk/lib/tkextlib/tcllib/datefield.rb b/ext/tk/lib/tkextlib/tcllib/datefield.rb index bd84488101..2244dd7a9a 100644 --- a/ext/tk/lib/tkextlib/tcllib/datefield.rb +++ b/ext/tk/lib/tkextlib/tcllib/datefield.rb @@ -24,7 +24,7 @@ TkPackage.require('datefield') module Tk module Tcllib - class Datefield < TkEntry + class Datefield < Tk::Entry PACKAGE_NAME = 'datefield'.freeze def self.package_name PACKAGE_NAME diff --git a/ext/tk/lib/tkextlib/tcllib/ico.rb b/ext/tk/lib/tkextlib/tcllib/ico.rb index 3beeb11a4d..8c92926a4c 100644 --- a/ext/tk/lib/tkextlib/tcllib/ico.rb +++ b/ext/tk/lib/tkextlib/tcllib/ico.rb @@ -94,8 +94,10 @@ class Tk::Tcllib::ICO if keys.key?('name') @path = keys['name'].to_s else - @path = Tk_Image_ID.join(TkCore::INTERP._ip_id_) - Tk_Image_ID[1].succ! + Tk_Image_ID.mutex.synchronize{ + @path = Tk_Image_ID.join(TkCore::INTERP._ip_id_) + Tk_Image_ID[1].succ! + } end tk_call_without_enc('::ico::getIcon', file, index, '-name', @path, '-format', 'image', *hash_kv(keys, true)) diff --git a/ext/tk/lib/tkextlib/tcllib/ip_entry.rb b/ext/tk/lib/tkextlib/tcllib/ip_entry.rb index 8c9e0bd683..c4b8240c04 100644 --- a/ext/tk/lib/tkextlib/tcllib/ip_entry.rb +++ b/ext/tk/lib/tkextlib/tcllib/ip_entry.rb @@ -18,7 +18,7 @@ TkPackage.require('ipentry') module Tk module Tcllib - class IP_Entry < TkEntry + class IP_Entry < Tk::Entry PACKAGE_NAME = 'ipentry'.freeze def self.package_name PACKAGE_NAME diff --git a/ext/tk/lib/tkextlib/tcllib/plotchart.rb b/ext/tk/lib/tkextlib/tcllib/plotchart.rb index f5f344ceb3..06ab20f3e6 100644 --- a/ext/tk/lib/tkextlib/tcllib/plotchart.rb +++ b/ext/tk/lib/tkextlib/tcllib/plotchart.rb @@ -225,7 +225,7 @@ module Tk::Tcllib::Plotchart end ############################ - class XYPlot < TkCanvas + class XYPlot < Tk::Canvas include ChartMethod TkCommandNames = [ @@ -247,7 +247,7 @@ module Tk::Tcllib::Plotchart @xaxis = args.shift @yaxis = args.shift - if parent.kind_of?(TkCanvas) + if parent.kind_of?(Tk::Canvas) @path = parent.path else super(parent, *args) # create canvas widget @@ -265,7 +265,9 @@ module Tk::Tcllib::Plotchart private :_create_chart def __destroy_hook__ - Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path) + Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.mutex.synchronize{ + Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path) + } end def plot(series, x, y) @@ -337,7 +339,7 @@ module Tk::Tcllib::Plotchart end ############################ - class PolarPlot < TkCanvas + class PolarPlot < Tk::Canvas include ChartMethod TkCommandNames = [ @@ -356,7 +358,7 @@ module Tk::Tcllib::Plotchart @radius_data = args.shift - if parent.kind_of?(TkCanvas) + if parent.kind_of?(Tk::Canvas) @path = parent.path else super(parent, *args) # create canvas widget @@ -374,7 +376,9 @@ module Tk::Tcllib::Plotchart private :_create_chart def __destroy_hook__ - Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path) + Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.mutex.synchronize{ + Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path) + } end def plot(series, radius, angle) @@ -395,7 +399,7 @@ module Tk::Tcllib::Plotchart Polarplot = PolarPlot ############################ - class IsometricPlot < TkCanvas + class IsometricPlot < Tk::Canvas include ChartMethod TkCommandNames = [ @@ -430,7 +434,7 @@ module Tk::Tcllib::Plotchart @stepsize = args.shift end - if parent.kind_of?(TkCanvas) + if parent.kind_of?(Tk::Canvas) @path = parent.path else super(parent, *args) # create canvas widget @@ -475,7 +479,7 @@ module Tk::Tcllib::Plotchart Isometricplot = IsometricPlot ############################ - class Plot3D < TkCanvas + class Plot3D < Tk::Canvas include ChartMethod TkCommandNames = [ @@ -500,7 +504,7 @@ module Tk::Tcllib::Plotchart @yaxis = args.shift @zaxis = args.shift - if parent.kind_of?(TkCanvas) + if parent.kind_of?(Tk::Canvas) @path = parent.path else super(parent, *args) # create canvas widget @@ -557,7 +561,7 @@ module Tk::Tcllib::Plotchart end ############################ - class Piechart < TkCanvas + class Piechart < Tk::Canvas include ChartMethod TkCommandNames = [ @@ -566,7 +570,7 @@ module Tk::Tcllib::Plotchart ].freeze def initialize(*args) # args := ([parent] [, keys]) - if args[0].kind_of?(TkCanvas) + if args[0].kind_of?(Tk::Canvas) parent = args.shift @path = parent.path else @@ -588,7 +592,7 @@ module Tk::Tcllib::Plotchart end ############################ - class Barchart < TkCanvas + class Barchart < Tk::Canvas include ChartMethod TkCommandNames = [ @@ -626,7 +630,7 @@ module Tk::Tcllib::Plotchart @series_size = args.shift end - if parent.kind_of?(TkCanvas) + if parent.kind_of?(Tk::Canvas) @path = parent.path else super(parent, *args) # create canvas widget @@ -645,7 +649,9 @@ module Tk::Tcllib::Plotchart private :_create_chart def __destroy_hook__ - Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path) + Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.mutex.synchronize{ + Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path) + } end def plot(series, dat, col=None) @@ -672,7 +678,7 @@ module Tk::Tcllib::Plotchart end ############################ - class Timechart < TkCanvas + class Timechart < Tk::Canvas include ChartMethod TkCommandNames = [ @@ -699,7 +705,7 @@ module Tk::Tcllib::Plotchart @time_end = args.shift @items = args.shift - if parent.kind_of?(TkCanvas) + if parent.kind_of?(Tk::Canvas) @path = parent.path else super(parent, *args) # create canvas widget @@ -733,7 +739,7 @@ module Tk::Tcllib::Plotchart end ############################ - class Gnattchart < TkCanvas + class Gnattchart < Tk::Canvas include ChartMethod TkCommandNames = [ @@ -772,7 +778,7 @@ module Tk::Tcllib::Plotchart @text_width = None end - if parent.kind_of?(TkCanvas) + if parent.kind_of?(Tk::Canvas) @path = parent.path else super(parent, *args) # create canvas widget @@ -834,23 +840,38 @@ module Tk::Tcllib::Plotchart ############################ class PlotSeries < TkObject SeriesID_TBL = TkCore::INTERP.create_table - Series_ID = ['series'.freeze, '00000'.taint].freeze - TkCore::INTERP.init_ip_env{ SeriesID_TBL.clear } + + (Series_ID = ['series'.freeze, '00000'.taint]).instance_eval{ + @mutex = Mutex.new + def mutex; @mutex; end + freeze + } + TkCore::INTERP.init_ip_env{ + SeriesID_TBL.mutex.synchronize{ SeriesID_TBL.clear } + } def self.id2obj(chart, id) path = chart.path - return id unless SeriesID_TBL[path] - SeriesID_TBL[path][id]? SeriesID_TBL[path][id]: id + SeriesID_TBL.mutex.synchronize{ + if SeriesID_TBL[path] + SeriesID_TBL[path][id]? SeriesID_TBL[path][id]: id + else + id + end + } end def initialize(chart, keys=nil) @parent = @chart_obj = chart @ppath = @chart_obj.path - @path = @series = @id = Series_ID.join(TkCore::INTERP._ip_id_) - # SeriesID_TBL[@id] = self - SeriesID_TBL[@ppath] = {} unless SeriesID_TBL[@ppath] - SeriesID_TBL[@ppath][@id] = self - Series_ID[1].succ! + Series_ID.mutex.synchronize{ + @path = @series = @id = Series_ID.join(TkCore::INTERP._ip_id_) + Series_ID[1].succ! + } + SeriesID_TBL.mutex.synchronize{ + SeriesID_TBL[@ppath] ||= {} + SeriesID_TBL[@ppath][@id] = self + } dataconfig(keys) if keys.kind_of?(Hash) end diff --git a/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb b/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb index 92dde65ce7..b366e0198b 100644 --- a/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb +++ b/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb @@ -125,7 +125,9 @@ module Tk::Tcllib::Tkpiechart def delete tk_call_without_enc('::stooop::delete', @tag_key) - CItemID_TBL[@path].delete(@id) if CItemID_TBL[@path] + CItemID_TBL.mutex.synchronize{ + CItemID_TBL[@path].delete(@id) if CItemID_TBL[@path] + } self end @@ -184,8 +186,10 @@ module Tk::Tcllib::Tkpiechart @id = "slices(#{@tag_key})" @tag = TkcNamedTag.new(@pie.canvas, @id) - CItemID_TBL[@path] = {} unless CItemID_TBL[@path] - CItemID_TBL[@path][@id] = self + CItemID_TBL.mutex.synchronize{ + CItemID_TBL[@path] = {} unless CItemID_TBL[@path] + CItemID_TBL[@path][@id] = self + } end def tag_key @@ -200,7 +204,9 @@ module Tk::Tcllib::Tkpiechart def delete tk_call_without_enc('pie::deleteSlice', @pie.tag_key, @tag_key) - CItemID_TBL[@path].delete(@id) if CItemID_TBL[@path] + CItemID_TBL.mutex.synchronize{ + CItemID_TBL[@path].delete(@id) if CItemID_TBL[@path] + } @pie._delete_slice(self) self end |