Quantcast

Don't attempt to expand parameters when StarTip is passed as self.

Scott Sibley [08-07-10 - 20:42]
Don't attempt to expand parameters when StarTip is passed as self.
Filename
Modules/DeadlyAnnounce.lua
Modules/Text.lua
StarTip.lua
diff --git a/Modules/DeadlyAnnounce.lua b/Modules/DeadlyAnnounce.lua
index 7c47c55..3687c76 100644
--- a/Modules/DeadlyAnnounce.lua
+++ b/Modules/DeadlyAnnounce.lua
@@ -56,7 +56,10 @@ function mod:InitializeDBM()
 	local text = nil

 	local function ShowAnnounce(t)
-		tinsert(history, t.text)
+		local new = StarTip.new()
+		new.text = t.text
+		new.time = _G.GetTime()
+		tinsert(history, new)
 	end

 	local function NewAnnounce(announce, _, spellId, ...)
@@ -145,7 +148,7 @@ local skip
 local function hideDW()
 	skip = true
 	GameTooltip:SetUnit("mouseover")
-	skip = nil
+	skip = false
 	mod.shown = false
 end

@@ -155,11 +158,13 @@ function mod:SetUnit()
 	if #history == 0 or skip then return end

 	if #history > 10 then
+		local tmp = history[#history]
+		StarTip.del(tmp)
 		tremove(history, #history)
 	end
 	GameTooltip:ClearLines()
 	GameTooltip:AddLine("--- DeadlyAnnounce ---")
-	for i = 1, #history do
+	for i = #history, 1, -1 do
 		GameTooltip:AddLine(history[i], 1, 1, 1)
 	end

diff --git a/Modules/Text.lua b/Modules/Text.lua
index 6beba74..7070e0e 100644
--- a/Modules/Text.lua
+++ b/Modules/Text.lua
@@ -140,7 +140,7 @@ local c
 if self.UnitIsPlayer("mouseover") then
     c = self.RAID_CLASS_COLORS[select(2, self.UnitClass("mouseover"))]
 else
-    c = StarTip:new()
+    c = StarTip.new()
     c.r, c.g, c.b = self.UnitSelectionColor("mouseover")
 end
 return self.unitName, c
@@ -159,13 +159,13 @@ if self.UnitExists("mouseovertarget") then
     if self.UnitIsPlayer("mouseovertarget") then
         c = self.RAID_CLASS_COLORS[select(2, self.UnitClass("mouseovertarget"))]
     else
-        c = StarTip:new()
+        c = StarTip.new()
         c.r, c.g, c.b = self.UnitSelectionColor("mouseovertarget")
     end
     local name = self.UnitName("mouseovertarget")
     return name, c
 else
-    return "None", StarTip:newDict("r", 1, "g", 1, "b", 1)
+    return "None", StarTip.newDict("r", 1, "g", 1, "b", 1)
 end
 ]],
         updating = true,
diff --git a/StarTip.lua b/StarTip.lua
index 5dd2ed4..e56ca7b 100644
--- a/StarTip.lua
+++ b/StarTip.lua
@@ -1,4 +1,5 @@
 StarTip = LibStub("AceAddon-3.0"):NewAddon("StarTip", "AceConsole-3.0", "AceHook-3.0", "AceEvent-3.0", "AceTimer-3.0")
+StarTip.__starref__ = true
 --local LibQTip = LibStub('LibQTip-1.0')
 local LibDBIcon = LibStub("LibDBIcon-1.0")
 local LSM = _G.LibStub("LibSharedMedia-3.0")
@@ -116,8 +117,13 @@ local options = {
 do
 	local pool = setmetatable({},{__mode='k'})

-	function StarTip:new(...)
+	function StarTip.new(...)
 		local t = next(pool)
+		if select(1, ...) == StarTip then
+			StarTip:Print("Warning: Passing self parameter to new.")
+			if not t then t = {} end
+			return t
+		end
 		if t then
 			pool[t] = nil
 			for i=1, select("#", ...) do
@@ -129,22 +135,32 @@ do
 		t.__starref__ = true
 		return t
 	end
-	function StarTip:newDict(...)
+	function StarTip.newDict(...)
+		local test
+		if select(1, ...) == StarTip then
+			test = true
+		end
 		local t = next(pool)
 		if t then
 			pool[t] = nil
 		else
 			t = {}
 		end
-		for i=1, select("#", ...), 2 do
+		for i=(test and 2 or 1), select("#", ...), 2 do
 			t[select(i, ...)] = select(i+1, ...)
 		end
 		t.__starref__ = true
 		return t
 	end
-	function StarTip.del(t, ...)
+	function StarTip.del(...)
+		local t = select(1, ...)
+		local test
+		if t == StarTip then
+			test = true
+			t = select(2, ...)
+		end
 		if type(t) ~= "table" or not t.__starref__ then return end
-		for i=1, select("#", ...) do
+		for i=(test and 2 or 1), select("#", ...) do
 			local t = select(i, ...)
 			if (t and type(t) ~= table) or t == nil then break end
 			for k, v in pairs(t) do