Quantcast

Fix option panel initialization

Jim Whitehead [07-15-18 - 09:29]
Fix option panel initialization
Filename
BlizzardFrames.lua
FrameOptionsPanel.lua
OptionsPanel.lua
diff --git a/BlizzardFrames.lua b/BlizzardFrames.lua
index bc39126..d20e26c 100755
--- a/BlizzardFrames.lua
+++ b/BlizzardFrames.lua
@@ -99,6 +99,11 @@ function panel:CreateOptions()
 end

 function panel.refresh()
+    xpcall(function()
+    if not panel.initialized then
+        panel:CreateOptions()
+    end
+
     local opt = addon.settings.blizzframes

     panel.PlayerFrame:SetChecked(opt.PlayerFrame)
@@ -112,9 +117,11 @@ function panel.refresh()
     panel.compactraid:SetChecked(opt.compactraid)
     --panel.compactparty:SetChecked(opt.compactparty)
     panel.boss:SetChecked(opt.boss)
+    end, geterrorhandler())
 end

 function panel.okay()
+    xpcall(function()
     local opt = addon.settings.blizzframes
     opt.PlayerFrame = not not panel.PlayerFrame:GetChecked()
     opt.PetFrame = not not panel.PetFrame:GetChecked()
@@ -127,6 +134,7 @@ function panel.okay()
     opt.compactraid = not not panel.compactraid:GetChecked()
     --opt.compactparty = not not panel.compactparty:GetChecked()
     opt.boss = not not panel.boss:GetChecked()
+    end, geterrorhandler())
 end

 InterfaceOptions_AddCategory(panel, addon.optpanels.ABOUT)
diff --git a/FrameOptionsPanel.lua b/FrameOptionsPanel.lua
index 7d5d7f2..1aeef8b 100755
--- a/FrameOptionsPanel.lua
+++ b/FrameOptionsPanel.lua
@@ -161,6 +161,7 @@ function panel:UpdateScrollFrame()
 end

 function panel.okay()
+    xpcall(function()
     -- Clear the existing blacklist
     for frame, value in pairs(state) do
         if not not value then
@@ -171,9 +172,16 @@ function panel.okay()
     end

     addon:FireMessage("BLACKLIST_CHANGED")
+    end, geterrorhandler())
 end

 function panel.refresh()
+    xpcall(function()
+
+    if not panel.initialized then
+        panel:CreateOptions()
+    end
+
     for frame in pairs(addon.ccframes) do
         local name = frame:GetName()
         if name then
@@ -190,6 +198,7 @@ function panel.refresh()
     end

     panel:UpdateScrollFrame()
+    end, geterrorhandler())
 end

 InterfaceOptions_AddCategory(panel, addon.optpanels.ABOUT)
diff --git a/OptionsPanel.lua b/OptionsPanel.lua
index c6caa96..b9f4342 100755
--- a/OptionsPanel.lua
+++ b/OptionsPanel.lua
@@ -134,8 +134,8 @@ end

 StaticPopupDialogs["CLIQUE_CONFIRM_PROFILE_DELETE"] = {
 	preferredIndex = STATICPOPUPS_NUMDIALOGS,
-    button1 = YES,
-    button2 = NO,
+    button1 = "Yes",
+    button2 = "No",
     hideOnEscape = 1,
     timeout = 0,
     whileDead = 1,
@@ -143,9 +143,9 @@ StaticPopupDialogs["CLIQUE_CONFIRM_PROFILE_DELETE"] = {

 StaticPopupDialogs["CLIQUE_NEW_PROFILE"] = {
 	preferredIndex = STATICPOPUPS_NUMDIALOGS,
-	text = TEXT("Enter the name of a new profile you'd like to create"),
-	button1 = TEXT(OKAY),
-	button2 = TEXT(CANCEL),
+	text = "Enter the name of a new profile you'd like to create",
+	button1 = "Okay",
+	button2 = "Cancel",
 	OnAccept = function(self)
 		local base = self:GetName()
 		local editbox = _G[base .. "EditBox"]
@@ -365,6 +365,12 @@ end

 -- Update the elements on the panel to the current state
 function panel.refresh()
+    xpcall(function()
+
+    if not panel.initialized then
+        panel:CreateOptions()
+    end
+
     -- Initialize the dropdowns
     local settings = addon.settings
     local currentProfile = addon.db:GetCurrentProfile()
@@ -386,13 +392,17 @@ function panel.refresh()
 	panel.stopcastingfix:SetChecked(settings.stopcastingfix)
     panel.specswap:SetChecked(settings.specswap)
     panel.specswap.EnableDisable()
+
+    end, geterrorhandler())
 end

 function panel.okay()
+    xpcall(function ()
+
     local settings = addon.settings
     local currentProfile = addon.db:GetCurrentProfile()

-	local changed = (not not panel.stopcastingfix:GetChecked()) ~= settings.stopcastingfix
+    local changed = (not not panel.stopcastingfix:GetChecked()) ~= settings.stopcastingfix

     -- Update the saved variables
     settings.downclick = not not panel.updown:GetChecked()
@@ -406,14 +416,13 @@ function panel.okay()
         settings[settingsKey] = UIDropDownMenu_GetSelectedValue(dropdown)
     end

-    if newProfile ~= currentProfile then
-        addon.db:SetProfile(newProfile)
-    end
     addon:UpdateCombatWatch()

-	if changed then
-		addon:FireMessage("BINDINGS_CHANGED")
-	end
+    if changed then
+        addon:FireMessage("BINDINGS_CHANGED")
+    end
+
+    end, geterrorhandler())
 end

 panel.cancel = panel.refresh