Quantcast

Moved the OnShow handler for MainPanel into MainPanel:Display() for better initial tab handling.

James D. Callahan III [06-22-10 - 06:26]
Moved the OnShow handler for MainPanel into MainPanel:Display() for better initial tab handling.
Filename
Frame.lua
diff --git a/Frame.lua b/Frame.lua
index 5379075..753f2c8 100644
--- a/Frame.lua
+++ b/Frame.lua
@@ -1030,13 +1030,9 @@ do
 			end
 		end
 		addon.db.profile.current_tab = id_num
-
-		-- If the MainPanel doesn't already have a current_tab, do not call ListFrame:Update() -
-		-- at this point, it's the first time the panel has been shown so the update will fire twice.
-		if MainPanel.current_tab then
-			ListFrame:Update(nil, false)
-		end
 		MainPanel.current_tab = id_num
+
+		ListFrame:Update(nil, false)
 		PlaySound("igCharacterInfoTab")
 	end

@@ -1257,19 +1253,6 @@ end	-- do-block
 -------------------------------------------------------------------------------
 -- MainPanel scripts/functions.
 -------------------------------------------------------------------------------
-MainPanel:SetScript("OnShow",
-		    function(self)
-			    -- If there is no current tab, this is the first time the panel has been
-			    -- shown so things must be initialized.
-			    if not self.current_tab then
-				    local current_tab = self.tabs[addon.db.profile.current_tab]
-				    local on_click = current_tab:GetScript("OnClick")
-
-				    on_click(current_tab)
-			    end
-			    self.sort_button:SetTextures()
-		    end)
-
 MainPanel:SetScript("OnHide",
 		    function(self)
 			    for spell_id, recipe in pairs(private.recipe_list) do
@@ -4215,7 +4198,21 @@ function MainPanel:Display(is_linked)
 		editbox.prev_search = nil
 	end
 	editbox:SetText(editbox.prev_search or _G.SEARCH)
-	ListFrame:Update(nil, false)
+
+	-- If there is no current tab, this is the first time the panel has been
+	-- shown so things must be initialized. In this case, ListFrame:Update()
+	-- will be called by the tab's OnClick handler.
+	if not self.current_tab then
+		local current_tab = self.tabs[addon.db.profile.current_tab]
+		local on_click = current_tab:GetScript("OnClick")
+
+		on_click(current_tab)
+
+		self.current_tab = addon.db.profile.current_tab
+	else
+		ListFrame:Update(nil, false)
+	end
+	self.sort_button:SetTextures()

 	self:UpdateTitle()
 	self:Show()