Quantcast

Fixed some potential issues with invalid data handling

Kevin Lyles [08-28-10 - 20:53]
Fixed some potential issues with invalid data handling
Filename
WeightsWatcher.lua
diff --git a/WeightsWatcher.lua b/WeightsWatcher.lua
index e98151e..31d0a98 100644
--- a/WeightsWatcher.lua
+++ b/WeightsWatcher.lua
@@ -241,6 +241,19 @@ local function upgradeData(dataType, varsName)
 	end
 end

+local function initializeAfterDataUpgrade()
+	ww_initializeParser()
+
+	ww_initializeWeightsConfig()
+
+	SLASH_WEIGHTSWATCHER1 = L["/ww"]
+	SLASH_WEIGHTSWATCHER2 = L["/weightswatcher"]
+	SlashCmdList["WEIGHTSWATCHER"] =
+		function(msg)
+			ww_commandHandler(msg)
+		end
+end
+
 function WeightsWatcher.OnInitialize()
 	loadGeneralInfo()

@@ -253,16 +266,7 @@ function WeightsWatcher.OnInitialize()
 		return
 	end

-	ww_initializeParser()
-
-	ww_initializeWeightsConfig()
-
-	SLASH_WEIGHTSWATCHER1 = L["/ww"]
-	SLASH_WEIGHTSWATCHER2 = L["/weightswatcher"]
-	SlashCmdList["WEIGHTSWATCHER"] =
-		function(msg)
-			ww_commandHandler(msg)
-		end
+	initializeAfterDataUpgrade()
 end

 StaticPopupDialogs["WW_INVALID_ACCOUNT_DATA"] = {
@@ -270,10 +274,11 @@ StaticPopupDialogs["WW_INVALID_ACCOUNT_DATA"] = {
 	button1 = L["Load Defaults"],
 	button2 = L["Disable WeightsWatcher"],
 	OnAccept = function(self, func)
+			ww_vars = copyDefaultAccountVars()
 			if not upgradeData("character", "ww_charVars") then
 				return
 			end
-			ww_initializeWeightsConfig()
+			initializeAfterDataUpgrade()
 		end,
 	OnCancel = function(self, func)
 			DisableAddOn("WeightsWatcher")
@@ -291,7 +296,7 @@ StaticPopupDialogs["WW_INVALID_CHARACTER_DATA"] = {
 	button2 = L["Disable WeightsWatcher"],
 	OnAccept = function(self, func)
 			ww_charVars = copyDefaultCharVars()
-			ww_initializeWeightsConfig()
+			initializeAfterDataUpgrade()
 		end,
 	OnCancel = function(self, func)
 			DisableAddOn("WeightsWatcher")