From a90378797b3ed69a6328e8c86b4f68b2f2656f93 Mon Sep 17 00:00:00 2001 From: Kevin Lyles Date: Sat, 28 Aug 2010 15:53:17 -0500 Subject: [PATCH] Fixed some potential issues with invalid data handling --- WeightsWatcher.lua | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) 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") -- 1.7.9.5