Skip to content

Commit

Permalink
ensure that dialog was closed even if exception is raised (bnc#873916)
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Apr 16, 2014
1 parent bdf7261 commit 56c8b67
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 47 deletions.
4 changes: 2 additions & 2 deletions library/cwm/src/modules/DialogTree.rb
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,9 @@ def Run(settings)
# @return [Symbol] wizard sequencer symbol
def RunAndHide(settings)
settings = deep_copy(settings)
ret = Run(settings)
Run(settings)
ensure
UI.CloseDialog
ret
end

# Display the dialog and run its event loop
Expand Down
95 changes: 50 additions & 45 deletions library/cwm/src/modules/TablePopup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -503,16 +503,19 @@ def askForNewOption(possible, editable, descr)
HSpacing(1)
)
UI.OpenDialog(widget)
UI.SetFocus(Id(:optname))
ret = nil
option = nil
while ret != :_tp_ok && ret != :_tp_cancel
ret = UI.UserInput
if ret == :_tp_ok
option = Convert.to_string(UI.QueryWidget(Id(:optname), :Value))
begin
UI.SetFocus(Id(:optname))
ret = nil
option = nil
while ret != :_tp_ok && ret != :_tp_cancel
ret = UI.UserInput
if ret == :_tp_ok
option = Convert.to_string(UI.QueryWidget(Id(:optname), :Value))
end
end
ensure
UI.CloseDialog
end
UI.CloseDialog
return nil if ret == :_tp_cancel
return option if Ops.get(known_keys, option, false)
Ops.get(val2key, option, option)
Expand Down Expand Up @@ -563,54 +566,56 @@ def singleOptionEditPopup(option)
HSpacing(1)
)
UI.OpenDialog(contents)
if Ops.get(popup_descr, "init") != nil
toEval = Convert.convert(
Ops.get(popup_descr, "init"),
:from => "any",
:to => "void (any, string)"
)
toEval.call(opt_id, opt_key)
end
ret = nil
event_descr = {}
while ret != :_tp_ok && ret != :_tp_cancel
event_descr2 = UI.WaitForEvent
event_descr2 = { "ID" => :_tp_ok } if Mode.test
ret = Ops.get(event_descr2, "ID")
if Ops.get(popup_descr, "handle") != nil
begin
if Ops.get(popup_descr, "init") != nil
toEval = Convert.convert(
Ops.get(popup_descr, "handle"),
Ops.get(popup_descr, "init"),
:from => "any",
:to => "void (any, string, map)"
:to => "void (any, string)"
)
toEval.call(opt_id, opt_key, event_descr2)
toEval.call(opt_id, opt_key)
end
if ret == :_tp_ok
val_type = Ops.get_symbol(popup_descr, "validate_type")
if val_type == :function
ret = nil
event_descr = {}
while ret != :_tp_ok && ret != :_tp_cancel
event_descr2 = UI.WaitForEvent
event_descr2 = { "ID" => :_tp_ok } if Mode.test
ret = Ops.get(event_descr2, "ID")
if Ops.get(popup_descr, "handle") != nil
toEval = Convert.convert(
Ops.get(popup_descr, "validate_function"),
Ops.get(popup_descr, "handle"),
:from => "any",
:to => "boolean (any, string, map)"
:to => "void (any, string, map)"
)
if toEval != nil
ret = nil if !toEval.call(opt_id, opt_key, event_descr2)
toEval.call(opt_id, opt_key, event_descr2)
end
if ret == :_tp_ok
val_type = Ops.get_symbol(popup_descr, "validate_type")
if val_type == :function
toEval = Convert.convert(
Ops.get(popup_descr, "validate_function"),
:from => "any",
:to => "boolean (any, string, map)"
)
if toEval != nil
ret = nil if !toEval.call(opt_id, opt_key, event_descr2)
end
elsif !CWM.validateWidget(popup_descr, event_descr2, opt_key)
ret = nil
end
elsif !CWM.validateWidget(popup_descr, event_descr2, opt_key)
ret = nil
end
end
if ret == :_tp_ok && Ops.get(popup_descr, "store") != nil
toEval = Convert.convert(
Ops.get(popup_descr, "store"),
:from => "any",
:to => "void (any, string)"
)
toEval.call(opt_id, opt_key)
end
ensure
UI.CloseDialog
end
if ret == :_tp_ok && Ops.get(popup_descr, "store") != nil
toEval = Convert.convert(
Ops.get(popup_descr, "store"),
:from => "any",
:to => "void (any, string)"
)
toEval.call(opt_id, opt_key)
end

UI.CloseDialog
Convert.to_symbol(ret)
end

Expand Down

0 comments on commit 56c8b67

Please sign in to comment.