ev/rwd.rb in rwdtinker-1.69 vs ev/rwd.rb in rwdtinker-1.70

- old
+ new

@@ -633,11 +633,11 @@ @@windows = {} # Kind of caching. @@helpwindows = {} # Kind of caching. def initialize(rwd, window=nil) rwd = rwd.join("\n") if rwd.kind_of?(Array) - + if @@windows[rwd].nil? @@windows[rwd] = {} @@helpwindows[rwd] = {} tree = XML.new(rwd) @@ -664,10 +664,12 @@ firstaction = "" html = [] vars = vars.deep_dup +begin # error wrap + vars.each do |key, value| if not key.empty? if value.respond_to? "to_s" @rwd.gsub!(/%%#{key}%%/, value.to_s) @rwd.gsub!(/%#{key}%/, value.to_s.to_html) @@ -719,10 +721,14 @@ html.gsub!(/\$RWD_FIRSTACTION\$/ , firstaction) html.gsub!(/\$RWD_FOCUS\$/ , focus) html end + + rescue + $stderr.puts "error in RWDWindow - render method" + end end class RWDMessage < RWDWindow def initialize(msg) super("<window title='RWD Message' nobackbuttons noclosebutton><p>#{msg}</p><back/></window>") @@ -761,12 +767,14 @@ super("<window title='RWD Message' nobackbuttons noclosebutton><p>Done.</p><i>(Some browsers don't close,<br>because of security reasons.)</i><horizontal><close/>#{exitbrowser ? "" : "<button caption='Again'/>"}</horizontal>#{exitbrowser ? "<closewindow/>" : ""}</window>") end end class RWDialog + def initialize(xml) - @rwd_xml = xml + @rwd_xml = $rwd_gui_tinker + # change from default ev - was xml @rwd_exitbrowser = false @rwd_history = [] @rwd_ignore_vars = [] @rwd_call_after_back = [] @rwd_time = Time.now @@ -816,10 +824,11 @@ done = false help = false back = false tab = "" + @rwd_progress_thread = nil @rwd_msgtype = nil if @rwd_progress_thread.nil? @rwd_download = nil @rwd_download_file = nil # Switches are used for checkboxes. @@ -831,11 +840,11 @@ @rwd_switches = Hash.new # Copy the vars from the window to vars. vars wil later on be copied to instance variables. post.sort.each do |key, value| - puts "Post: #{key} -> #{value.from_html.inspect}" if $rwd_debug + $stderr.puts "Post: #{key} -> #{value.from_html.inspect}" if $rwd_debug vars[key] = value.from_html end # Stack handling for rwd_action, rwd_window and rwd_tab. @@ -908,11 +917,11 @@ # Callback. if (not back) or @rwd_call_after_back.include?(@rwd_action) unless @rwd_action =~ /^rwd_/ - puts "Method: #{@rwd_action}(#{@rwd_args.join(", ")})" if $rwd_debug + puts "Method: #{@rwd_action}(#{@rwd_args.join(", ")})" if $rwd_debug if methods.include?(@rwd_action) method(@rwd_action).call(*@rwd_args) else puts "Method '%s' is not defined." % @rwd_action end @@ -946,11 +955,11 @@ end # just ignore. vars.sort.each do |key, value| - puts "Pre: #{key} -> #{value.inspect}" if $rwd_debug + puts "Pre: #{key} -> #{value.inspect}" if $rwd_debug end # Answer to browser. @@ -969,14 +978,21 @@ if not @rwd_msgtype.nil? res << RWDMessage.new(@rwd_msg).render(pda) if @rwd_msgtype == "message" res << RWDError.new(@rwd_msg).render(pda) if @rwd_msgtype == "error" res << @rwd_msg if @rwd_msgtype == "text" else - puts "Window: #{@rwd_window}" if $rwd_debug - puts "Tab: #{@rwd_tab}" if $rwd_debug + puts "Window: #{@rwd_window}" if $rwd_debug + puts "Tab: #{@rwd_tab}" if $rwd_debug - res << RWDWindow.new(@rwd_xml, @rwd_window).render(pda, @rwd_refresh_action, vars, @rwd_switches, help, @rwd_tab) - end +begin # error block + if @rwd_window.empty? + @rwd_window = "main" + end + res << RWDWindow.new($rwd_gui_tinker, @rwd_window).render(pda, @rwd_refresh_action, vars, @rwd_switches, help, @rwd_tab) +rescue + $stderr.puts "error in render" + end +end end end end return done