QuickDispatch now uses xpcall instead of pcall, fixed search box erroring on some searchs

This commit is contained in:
Tercio Jose
2022-10-14 13:21:58 -03:00
parent 50ed1cf776
commit 3f3d4db5f0
12 changed files with 65 additions and 63 deletions
+1 -1
View File
@@ -122,7 +122,7 @@ function DF:CreateAddOn (name, global_saved, global_table, options_table, broker
end
if (addon.OnInit) then
xpcall (addon.OnInit, geterrorhandler(), addon)
xpcall(addon.OnInit, geterrorhandler(), addon)
end
end
+14 -14
View File
@@ -234,7 +234,7 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t
f.db.aura_tracker.track_method = method
if (change_callback) then
DF:QuickDispatch (change_callback)
DF:QuickDispatch(change_callback)
end
if (method == 0x1) then
@@ -427,7 +427,7 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t
--refresh the buff blacklist frame
f.buff_ignored:DoRefresh()
DF:QuickDispatch (change_callback)
DF:QuickDispatch(change_callback)
--add to spells with the same name cache
same_name_spells_add (spellId)
@@ -458,7 +458,7 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t
--refresh the buff blacklist frame
f.buff_ignored:DoRefresh()
DF:QuickDispatch (change_callback)
DF:QuickDispatch(change_callback)
--add to spells with the same name cache
same_name_spells_add (spellId)
@@ -485,7 +485,7 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t
--refresh the buff blacklist frame
f.debuff_ignored:DoRefresh()
DF:QuickDispatch (change_callback)
DF:QuickDispatch(change_callback)
--add to spells with the same name cache
same_name_spells_add (spellId)
@@ -515,7 +515,7 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t
--refresh the buff blacklist frame
f.debuff_ignored:DoRefresh()
DF:QuickDispatch (change_callback)
DF:QuickDispatch(change_callback)
--add to spells with the same name cache
same_name_spells_add (spellId)
@@ -558,7 +558,7 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t
--refresh the buff blacklist frame
f.debuff_tracked:DoRefresh()
DF:QuickDispatch (change_callback)
DF:QuickDispatch(change_callback)
--add to spells with the same name cache
same_name_spells_add (spellId)
@@ -587,7 +587,7 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t
--refresh the buff blacklist frame
f.debuff_tracked:DoRefresh()
DF:QuickDispatch (change_callback)
DF:QuickDispatch(change_callback)
--add to spells with the same name cache
same_name_spells_add (spellId)
@@ -614,7 +614,7 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t
f.buff_tracked:DoRefresh()
--callback the addon
DF:QuickDispatch (change_callback)
DF:QuickDispatch(change_callback)
--add to spells with the same name cache
same_name_spells_add (spellId)
@@ -646,7 +646,7 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t
f.buff_tracked:DoRefresh()
--callback the addon
DF:QuickDispatch (change_callback)
DF:QuickDispatch(change_callback)
--add to spells with the same name cache
same_name_spells_add (spellId)
@@ -793,7 +793,7 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t
db ["".. (spellID or "")] = nil -- cleanup...
parent [member]:DoRefresh()
if (removeFunc) then
DF:QuickDispatch (removeFunc)
DF:QuickDispatch(removeFunc)
end
end
@@ -874,23 +874,23 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t
local buff_tracked = createAuraScrollBox (f_auto, "$parentBuffTracked", "BuffTrackerScroll", f.LocTexts.BUFFS_TRACKED, f.db.aura_tracker.buff_tracked, function()
if (change_callback) then
DF:QuickDispatch (change_callback)
DF:QuickDispatch(change_callback)
end
end)
local debuff_tracked = createAuraScrollBox (f_auto, "$parentDebuffTracked", "DebuffTrackerScroll", f.LocTexts.DEBUFFS_TRACKED, f.db.aura_tracker.debuff_tracked, function()
if (change_callback) then
DF:QuickDispatch (change_callback)
DF:QuickDispatch(change_callback)
end
end)
local buff_ignored = createAuraScrollBox (f_auto, "$parentBuffIgnored", "BuffIgnoredScroll", f.LocTexts.BUFFS_IGNORED, f.db.aura_tracker.buff_banned, function()
if (change_callback) then
DF:QuickDispatch (change_callback)
DF:QuickDispatch(change_callback)
end
end)
local debuff_ignored = createAuraScrollBox (f_auto, "$parentDebuffIgnored", "DebuffIgnoredScroll", f.LocTexts.DEBUFFS_IGNORED, f.db.aura_tracker.debuff_banned, function()
if (change_callback) then
DF:QuickDispatch (change_callback)
DF:QuickDispatch(change_callback)
end
end)
+14 -11
View File
@@ -1,6 +1,6 @@
local dversion = 380
local dversion = 381
local major, minor = "DetailsFramework-1.0", dversion
local DF, oldminor = LibStub:NewLibrary(major, minor)
@@ -1770,6 +1770,9 @@ end
label.text = (languageTable and languageTable[widgetTable.namePhraseId]) or formatOptionNameWithColon(widgetTable.name, useColon) or widgetTable.namePhraseId or ""
label:SetTemplate(widgetTable.text_template or textTemplate)
label:ClearAllPoints()
colorpick:ClearAllPoints()
if (widgetTable.boxfirst or useBoxFirstOnAllWidgets) then
label:SetPoint("left", colorpick, "right", 2)
colorpick:SetPoint(currentXOffset, currentYOffset)
@@ -3934,7 +3937,7 @@ local specs_per_class = {
["EVOKER"] = {1467, 1468},
}
function DF:GetClassSpecIDs (class)
function DF:GetClassSpecIDs(class)
return specs_per_class [class]
end
@@ -3943,19 +3946,19 @@ local dispatch_error = function(context, errortext)
end
--safe call an external func with payload and without telling who is calling
function DF:QuickDispatch (func, ...)
function DF:QuickDispatch(func, ...)
if (type(func) ~= "function") then
return
end
local okay, errortext = pcall(func, ...)
local okay, errortext = xpcall(func, geterrorhandler(), ...)
if (not okay) then
--trigger an error msg
dispatch_error (_, errortext)
dispatch_error(_, errortext)
return
end
return true
end
@@ -3964,7 +3967,7 @@ function DF:Dispatch(func, ...)
return dispatch_error (_, "DF:Dispatch expect a function as parameter 1.")
end
local dispatchResult = {xpcall (func, geterrorhandler(), ...)}
local dispatchResult = {xpcall(func, geterrorhandler(), ...)}
local okay = dispatchResult[1]
if (not okay) then
@@ -3977,14 +3980,14 @@ function DF:Dispatch(func, ...)
end
--[=[
DF:CoreDispatch (func, context, ...)
DF:CoreDispatch(func, context, ...)
safe call a function making a error window with what caused, the context and traceback of the error
this func is only used inside the framework for sensitive calls where the func must run without errors
@func = the function which will be called
@context = what made the function be called
... parameters to pass in the function call
--]=]
function DF:CoreDispatch (context, func, ...)
function DF:CoreDispatch(context, func, ...)
if (type(func) ~= "function") then
local stack = debugstack(2)
local errortext = "D!Framework " .. context .. " error: invalid function to call\n====================\n" .. stack .. "\n====================\n"
+5 -3
View File
@@ -54,7 +54,7 @@ detailsFramework.TooltipHandlerMixin = {
if (type(tooltipText) == "function") then
local tooltipFunction = tooltipText
local gotTooltip, tooltipString = pcall(tooltipFunction)
local gotTooltip, tooltipString = xpcall(tooltipFunction, geterrorhandler())
if (gotTooltip) then
tooltipText = tooltipString
end
@@ -353,9 +353,11 @@ detailsFramework.ScriptHookMixin = {
end
for i, func in ipairs(hooks) do
local success, canInterrupt = pcall(func, ...)
local success, canInterrupt = xpcall(func, geterrorhandler(), ...)
if (not success) then
error("Details! Framework: " .. event .. " hook for " .. self:GetName() .. ": " .. canInterrupt)
--error("Details! Framework: " .. event .. " hook for " .. self:GetName() .. ": " .. canInterrupt)
return false
elseif (canInterrupt) then
return true
+16 -16
View File
@@ -1589,7 +1589,7 @@ function detailsFramework:IconPick (callback, close_when_select, param1, param2)
local accept_custom_icon = function()
local path = detailsFramework.IconPickFrame.customIconEntry:GetText()
detailsFramework:QuickDispatch (detailsFramework.IconPickFrame.callback, path, detailsFramework.IconPickFrame.param1, detailsFramework.IconPickFrame.param2)
detailsFramework:QuickDispatch(detailsFramework.IconPickFrame.callback, path, detailsFramework.IconPickFrame.param1, detailsFramework.IconPickFrame.param2)
if (detailsFramework.IconPickFrame.click_close) then
close_button:Click()
@@ -1658,7 +1658,7 @@ function detailsFramework:IconPick (callback, close_when_select, param1, param2)
local onClickFunction = function(self)
detailsFramework:QuickDispatch (detailsFramework.IconPickFrame.callback, self.icon:GetTexture(), detailsFramework.IconPickFrame.param1, detailsFramework.IconPickFrame.param2)
detailsFramework:QuickDispatch(detailsFramework.IconPickFrame.callback, self.icon:GetTexture(), detailsFramework.IconPickFrame.param1, detailsFramework.IconPickFrame.param2)
if (detailsFramework.IconPickFrame.click_close) then
close_button:Click()
@@ -3782,7 +3782,7 @@ function detailsFramework:CreateSimpleListBox (parent, name, title, empty_text,
f.list_table = list_table
f.func = function(self, button, value)
--onclick (value)
detailsFramework:QuickDispatch (onclick, value)
detailsFramework:QuickDispatch(onclick, value)
f:Refresh()
end
f.widgets = {}
@@ -3795,7 +3795,7 @@ function detailsFramework:CreateSimpleListBox (parent, name, title, empty_text,
if (f.options.x_button_func) then
local original_X_function = f.options.x_button_func
f.options.x_button_func = function(self, button, value)
detailsFramework:QuickDispatch (original_X_function, value)
detailsFramework:QuickDispatch(original_X_function, value)
f:Refresh()
end
end
@@ -3976,7 +3976,7 @@ function detailsFramework:CreateKeybindBox (parent, name, data, callback, width,
--build data table for the character class
local _, unitClass = UnitClass("player")
if (unitClass) then
local specIds = detailsFramework:GetClassSpecIDs (unitClass)
local specIds = detailsFramework:GetClassSpecIDs(unitClass)
if (specIds) then
for _, specId in ipairs(specIds) do
data [specId] = {}
@@ -4018,7 +4018,7 @@ function detailsFramework:CreateKeybindBox (parent, name, data, callback, width,
--format the button label and icon with the spec information
local className, class = UnitClass("player")
local i = 1
local specIds = detailsFramework:GetClassSpecIDs (class)
local specIds = detailsFramework:GetClassSpecIDs(class)
for index, specId in ipairs(specIds) do
local button = new_keybind_frame ["SpecButton" .. index]
@@ -4086,7 +4086,7 @@ function detailsFramework:CreateKeybindBox (parent, name, data, callback, width,
enter_the_key:Hide()
new_keybind_frame.keybindScroll:UpdateScroll()
detailsFramework:QuickDispatch (callback)
detailsFramework:QuickDispatch(callback)
end
local set_keybind_key = function(self, button, keybindIndex)
@@ -4111,14 +4111,14 @@ function detailsFramework:CreateKeybindBox (parent, name, data, callback, width,
local set_action_text = function(keybindIndex, _, text)
local keybind = new_keybind_frame.CurrentKeybindEditingSet [keybindIndex]
keybind.actiontext = text
detailsFramework:QuickDispatch (callback)
detailsFramework:QuickDispatch(callback)
end
local set_action_on_espace_press = function(textentry, capsule)
capsule = capsule or textentry.MyObject
local keybind = new_keybind_frame.CurrentKeybindEditingSet [capsule.CurIndex]
textentry:SetText(keybind.actiontext)
detailsFramework:QuickDispatch (callback)
detailsFramework:QuickDispatch(callback)
end
local lock_textentry = {
@@ -4134,7 +4134,7 @@ function detailsFramework:CreateKeybindBox (parent, name, data, callback, width,
local keybind = new_keybind_frame.CurrentKeybindEditingSet [keybindIndex]
keybind.action = value
new_keybind_frame.keybindScroll:UpdateScroll()
detailsFramework:QuickDispatch (callback)
detailsFramework:QuickDispatch(callback)
end
local fill_action_dropdown = function()
@@ -4176,13 +4176,13 @@ function detailsFramework:CreateKeybindBox (parent, name, data, callback, width,
detailsFramework:Msg("Keybind copied to " .. (specName or ""))
end
end
detailsFramework:QuickDispatch (callback)
detailsFramework:QuickDispatch(callback)
end
local delete_keybind = function(self, button, keybindIndex)
tremove(new_keybind_frame.CurrentKeybindEditingSet, keybindIndex)
new_keybind_frame.keybindScroll:UpdateScroll()
detailsFramework:QuickDispatch (callback)
detailsFramework:QuickDispatch(callback)
end
local newTitle = detailsFramework:CreateLabel(new_keybind_frame, "Create a new Keybind:", 12, "silver")
@@ -5710,7 +5710,7 @@ function detailsFramework:CreateLoadFilterParser (callback)
--print("Plater Script Update:", event, ...)
detailsFramework:QuickDispatch (callback, f.EncounterIDCached)
detailsFramework:QuickDispatch(callback, f.EncounterIDCached)
end)
end
@@ -5733,7 +5733,7 @@ function detailsFramework:PassLoadFilters(loadTable, encounterID)
if (passLoadClass) then
--if is allowed to load on this class, check if the talents isn't from another class
local _, classFileName = UnitClass("player")
local specsForThisClass = detailsFramework:GetClassSpecIDs (classFileName)
local specsForThisClass = detailsFramework:GetClassSpecIDs(classFileName)
canCheckTalents = false
@@ -5970,7 +5970,7 @@ function detailsFramework:OpenLoadConditionsPanel(optionsTable, callback, frameO
--create the radio group for character spec
if IS_WOW_PROJECT_MAINLINE then
local specs = {}
for _, specID in ipairs(detailsFramework:GetClassSpecIDs (select(2, UnitClass("player")))) do
for _, specID in ipairs(detailsFramework:GetClassSpecIDs(select(2, UnitClass("player")))) do
local specID, specName, specDescription, specIcon, specBackground, specRole, specClass = DetailsFramework.GetSpecializationInfoByID (specID)
tinsert(specs, {
name = specName,
@@ -6474,7 +6474,7 @@ detailsFramework.DataScrollFunctions = {
end
if (line:GetParent().OnUpdateLineHook) then
detailsFramework:CoreDispatch ((line:GetName() or "ScrollBoxDataScrollUpdateLineHook") .. ":UpdateLineHook()", line:GetParent().OnUpdateLineHook, line, lineIndex, data)
detailsFramework:CoreDispatch((line:GetName() or "ScrollBoxDataScrollUpdateLineHook") .. ":UpdateLineHook()", line:GetParent().OnUpdateLineHook, line, lineIndex, data)
end
end,
}
+1 -1
View File
@@ -775,7 +775,7 @@ local SwitchOnClick = function(self, button, forced_value, value)
value = slider:return_func (value)
end
local success, errorText = xpcall (slider.OnSwitch, geterrorhandler(), slider, slider.FixedValue, value)
local success, errorText = xpcall(slider.OnSwitch, geterrorhandler(), slider, slider.FixedValue, value)
if (not success) then
return
end
+5 -5
View File
@@ -5884,14 +5884,14 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
if (_detalhes.in_combat and _detalhes.tabela_vigente) then
tinsert(_detalhes_global.exit_log, "3 - Leaving current combat.")
currentStep = "Leaving Current Combat"
xpcall (_detalhes.SairDoCombate, saver_error)
xpcall(_detalhes.SairDoCombate, saver_error)
_detalhes.can_panic_mode = true
end
if (_detalhes.CheckSwitchOnLogon and _detalhes.tabela_instancias[1] and _detalhes.tabela_instancias and getmetatable(_detalhes.tabela_instancias[1])) then
tinsert(_detalhes_global.exit_log, "4 - Reversing switches.")
currentStep = "Check Switch on Logon"
xpcall (_detalhes.CheckSwitchOnLogon, saver_error)
xpcall(_detalhes.CheckSwitchOnLogon, saver_error)
end
if (_detalhes.wipe_full_config) then
@@ -5904,11 +5904,11 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
--save the config
tinsert(_detalhes_global.exit_log, "6 - Saving Config.")
currentStep = "Saving Config"
xpcall (_detalhes.SaveConfig, saver_error)
xpcall(_detalhes.SaveConfig, saver_error)
tinsert(_detalhes_global.exit_log, "7 - Saving Profiles.")
currentStep = "Saving Profile"
xpcall (_detalhes.SaveProfile, saver_error)
xpcall(_detalhes.SaveProfile, saver_error)
--save the nicktag cache
tinsert(_detalhes_global.exit_log, "8 - Saving nicktag cache.")
@@ -5916,7 +5916,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
local saveNicktabCache = function()
_detalhes_database.nick_tag_cache = Details.CopyTable(_detalhes_database.nick_tag_cache)
end
xpcall (saveNicktabCache, saver_error)
xpcall(saveNicktabCache, saver_error)
end)
-- ~parserstart ~startparser ~cleu
+1 -1
View File
@@ -593,7 +593,7 @@
--show the plugin window
if (pluginObject.RefreshWindow and callRefresh) then
DetailsFramework:QuickDispatch (pluginObject.RefreshWindow)
DetailsFramework:QuickDispatch(pluginObject.RefreshWindow)
end
--highlight the plugin button on the menu
+1 -1
View File
@@ -166,7 +166,7 @@ end
if (button.tooltip) then
if (button.menu) then
_detalhes.gump:QuickDispatch (button.menu)
_detalhes.gump:QuickDispatch(button.menu)
local next_check = 0.8
+4 -7
View File
@@ -6901,16 +6901,13 @@ end
-- ~19 - search results
do
--[=
local buildSection = function(sectionFrame)
local sectionOptions = {
}
DF:BuildMenu(sectionFrame, sectionOptions, startX, startY-20, heightSize, false, options_text_template, options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template)
--local sectionOptions = {}
--DF:BuildMenu(sectionFrame, sectionOptions, startX, startY-20, heightSize, false, options_text_template, options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template)
end
tinsert(Details.optionsSection, buildSection)
--]=]
end
+1 -1
View File
@@ -165,7 +165,7 @@ function Details.OpenRunCodeWindow()
if (func) then
DF:SetEnvironment(func)
DF:QuickDispatch (func)
DF:QuickDispatch(func)
else
errortext_frame:Flash(0.2, 0.2, 0.4, true, nil, nil, "NONE")
end
+2 -2
View File
@@ -91,10 +91,10 @@ function _detalhes:SaveConfig()
_detalhes_database.tabela_pets = _detalhes.tabela_pets.pets
end
xpcall (_detalhes.TimeDataCleanUpTemporary, _detalhes.saver_error_func)
xpcall(_detalhes.TimeDataCleanUpTemporary, _detalhes.saver_error_func)
--buffs
xpcall (_detalhes.Buffs.SaveBuffs, _detalhes.saver_error_func)
xpcall(_detalhes.Buffs.SaveBuffs, _detalhes.saver_error_func)
--date
_detalhes.last_day = date ("%d")