diff Config.lua @ 68:710f03653aaf

When the track at option of a group is overridden, the default is no longer passed by reference but copied whenever it is a table.
author Zerotorescue
date Thu, 23 Dec 2010 13:57:48 +0100
parents ac1189599769
children 6329ee822172
line wrap: on
line diff
--- a/Config.lua	Thu Dec 23 13:38:27 2010 +0100
+++ b/Config.lua	Thu Dec 23 13:57:48 2010 +0100
@@ -22,7 +22,9 @@
 		elseif value and info.arg then
 			-- If this override is now enabled, we need to copy the default into this field (unless it is not nil (which is supposed to be impossible), in which case we'll use the already selected value)
 			
-			addon.db.profile.groups[groupName][info.arg] = addon:GetOptionByKey(groupName, info.arg);
+			local inheritedValue = addon:GetOptionByKey(groupName, info.arg);
+			
+			addon.db.profile.groups[groupName][info.arg] = (type(inheritedValue) ~= "table" and inheritedValue) or CopyTable(inheritedValue); -- copying defaults by reference would let one (unintendedly) change the defaults
 		end
 	end
 	
@@ -55,13 +57,9 @@
 	local groupName = groupIdToName[info[2]];
 	local optionName = info[#info];
 	
-	if addon.db.profile.groups[groupName][optionName] ~= nil then
-		return addon.db.profile.groups[groupName][optionName][value];
-	elseif addon.db.profile.defaults[optionName] then
-		return addon.db.profile.defaults[optionName][value];
-	else
-		return nil;
-	end
+	local multiSelectValue = addon:GetOptionByKey(groupName, optionName);
+	
+	return multiSelectValue and multiSelectValue[value];
 end
 
 local function GetDisabled(info)
@@ -1462,8 +1460,12 @@
 							
 							return temp;
 						end,
-						get = function(i, v) return addon.db.profile.defaults.trackAtCharacters[v]; end,
-						set = function(i, v, e) addon.db.profile.defaults.trackAtCharacters[v] = e or nil; end,
+						get = function(i, v)
+							return addon.db.profile.defaults.trackAtCharacters[v];
+						end,
+						set = function(i, v, e)
+							addon.db.profile.defaults.trackAtCharacters[v] = e or nil;
+						end,
 						dialogControl = "Dropdown", -- this is not standard, normal multiselect control gives us a list of all chars with toggle-boxes. UGLY! We want a multiselect-box instead.
 					},
 				},