Quantcast

Fix ticket 241 by guarding against a missing script source.

Johnny C. Lam [05-21-13 - 05:10]
Fix ticket 241 by guarding against a missing script source.

Sometimes, the script source may not be present because the addon that
provided it is removed.  Protect against this by checking for nil tables
appropriately.

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@917 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
OvaleCompile.lua
OvaleOptions.lua
diff --git a/OvaleCompile.lua b/OvaleCompile.lua
index a3c90f0..f201ad2 100644
--- a/OvaleCompile.lua
+++ b/OvaleCompile.lua
@@ -809,7 +809,12 @@ end
 function OvaleCompile:Compile()
 	local profile = OvaleOptions:GetProfile()
 	local source = profile.source
-	local code = OvaleScripts.script[OvalePaperDoll.class][source].code
+	local code
+	if source and OvaleScripts.script[OvalePaperDoll.class][source] then
+		code = OvaleScripts.script[OvalePaperDoll.class][source].code
+	else
+		code = ""
+	end
 	CompileScript(code)
 	Ovale.refreshNeeded.player = true
 	Ovale:UpdateFrame()
diff --git a/OvaleOptions.lua b/OvaleOptions.lua
index fc49030..b0c6179 100644
--- a/OvaleOptions.lua
+++ b/OvaleOptions.lua
@@ -317,7 +317,12 @@ local self_options =
 					end,
 					get = function(info)
 						local source = OvaleOptions.db.profile.source
-						local code = OvaleScripts.script[OvalePaperDoll.class][source].code
+						local code
+						if source and OvaleScripts.script[OvalePaperDoll.class][source] then
+							code = OvaleScripts.script[OvalePaperDoll.class][source].code
+						else
+							code = ""
+						end
 						return strgsub(code, "\t", "    ")
 					end,
 					set = function(info, v)
@@ -340,7 +345,12 @@ local self_options =
 					func = function()
 						local class = OvalePaperDoll.class
 						local source = OvaleOptions.db.profile.source
-						local code = OvaleScripts.script[class][source].code
+						local code
+						if source and OvaleScripts.script[OvalePaperDoll.class][source] then
+							code = OvaleScripts.script[OvalePaperDoll.class][source].code
+						else
+							code = ""
+						end
 						OvaleScripts.script[class]["custom"].code = code
 						OvaleOptions.db.profile.source = "custom"
 						OvaleOptions.db.profile.code = code