Quantcast

Fixed a memory leak related to the bars module

Scott Sibley [08-27-10 - 07:15]
Fixed a memory leak related to the bars module
Filename
Modules/Bars.lua
Modules/Position.lua
Modules/Text.lua
config.lua
diff --git a/Modules/Bars.lua b/Modules/Bars.lua
index 7d510d2..0dfbc57 100644
--- a/Modules/Bars.lua
+++ b/Modules/Bars.lua
@@ -142,7 +142,7 @@ function mod:SetUnit()
 	updateBars()
 	if self.db.profile.showHP then self.hpBar:Show() end
 	if self.db.profile.showMP then self.mpBar:Show() end
-	timer = timer or self:ScheduleRepeatingTimer(updateBars, .5)
+	--timer = timer or self:ScheduleRepeatingTimer(updateBars, .5)
 end

 function mod:SetItem()
@@ -202,18 +202,19 @@ function mod:UpdateHealth()

 	local color
 	if self.db.profile.useGradient then
-		color = {}
+		color = StarTip.new()
 		color.r, color.g, color.b = colorGradient(min/max)
 	elseif(UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit) or not UnitIsConnected(unit)) then
 		color = health[1]
 	elseif UnitIsPlayer(unit) then
 		color = RAID_CLASS_COLORS[select(2, UnitClass(unit))]
 	else
-		color = {}
+		color = StarTip.new()
 		color.r, color.g, color.b = UnitSelectionColor(unit)
 	end
 	if not color then color = health[0] end
 	self.hpBar:SetStatusBarColor(color.r, color.g, color.b)
+	StarTip.del(color)
 end

 function mod:UpdateMana()
diff --git a/Modules/Position.lua b/Modules/Position.lua
index 96fd17e..17f8076 100644
--- a/Modules/Position.lua
+++ b/Modules/Position.lua
@@ -221,7 +221,9 @@ local currentAnchor
 local xoffset, yoffset
 local positionTooltip = function()
 	local x, y = GetCursorPosition()
+
 	local effScale = GameTooltip:GetEffectiveScale()
+
 	if x ~= oldX or y ~= oldY then
 		GameTooltip:ClearAllPoints()
 		GameTooltip:SetPoint(currentAnchor, UIParent, "BOTTOMLEFT", (x + xoffset) / effScale, (y + yoffset) / effScale)
diff --git a/Modules/Text.lua b/Modules/Text.lua
index 2c391ad..3af6044 100644
--- a/Modules/Text.lua
+++ b/Modules/Text.lua
@@ -82,7 +82,7 @@ function copy(t)
 	return tmp
 end

-local defaults = {profile={titles=true, empty = true, lines = {}, refreshRate = 100}}
+local defaults = {profile={titles=true, empty = true, lines = {}, refreshRate = 500}}

 local defaultLines={
     [1] = {
@@ -430,7 +430,6 @@ function mod:OnEnable()
 	StarTip:SetOptionsDisabled(options, false)
 	self:CreateLines()
 	self.timer = LibTimer:New("Text module", self.db.profile.refreshRate, true, draw, nil, self.db.profile.errorLevel, self.db.profile.durationLimit)
-	self.timer:Start()
 	self.unitFrameFunkyTimer = LibTimer:New("Funky unit frames timer", 100, false, unitFrameFunkyFunction, nil, StarTip.db.profile.errorLevel)
 end

@@ -525,7 +524,6 @@ function mod:CreateLines()
     lines = setmetatable(llines, {__call=function(self)
         local lineNum = 0
 		GameTooltip:ClearLines()
-
         for i, v in ipairs(self) do
 			if v.enabled and not v.deleted then

@@ -1093,7 +1091,7 @@ local getGuild = function()
 end

 local ff = CreateFrame("Frame")
-function mod:SetUnit()
+function mod:SetUnit()
     if ff:GetScript("OnUpdate") then ff:SetScript("OnUpdate", nil) end

     environment.unitName = getName()
@@ -1165,5 +1163,8 @@ function mod:SetUnit()
     -- End

 	self.timer:Start()
-	self.unitFrameFunkyTimer:Start()
+
+	if GetMouseFocus() ~= UIParent then
+		self.unitFrameFunkyTimer:Start()
+	end
 end
diff --git a/config.lua b/config.lua
index 1883a61..658a408 100644
--- a/config.lua
+++ b/config.lua
@@ -13,11 +13,10 @@ StarTip.config = {
 		["background"] = "d9ccf16f",
 		["rows"] = 6,
 		["cols"] = 30,
-		["transition_timeout"] = 500,
 		["timeout"] = 5000,
 		["transition_speed"] = 50,
 		["widgets"] = {"widget_key_up", "widget_key_down"},
-		["layouts"] = {"layout_startip", "layout_histogram"},
+		["layouts"] = {"layout_histogram", "layout_startip"},
 		["font"] = {normal="Interface\\AddOns\\startip\\Fonts\\ttf-bitstream-vera-1.10\\VeraMo.ttf", bold="Interface\\AddOns\\startip\\Fonts\\ttf-bitstream-vera-1.10\\VeraMoBd.ttf", size=12},
 		--["font"] = {file = GameTooltipText:GetFont(), size = 12}
     },
@@ -140,7 +139,7 @@ end
 	},
 	["widget_mem_perc"] = {
 		type = "text",
-		value = [[
+		value = [[
 mem, percent, memdiff, totalMem, totaldiff = GetMemUsage("StarTip")
 if mem then
     if totaldiff == 0 then totaldiff = 1 end
@@ -150,8 +149,8 @@ end
 		align = ALIGN_PINGPONG,
 		direction = SCROLL_RIGHT,
 		cols = 30,
-		update = 500,
-		speed = 100,
+		update = 1000,
+		speed = 50,
 		dontRtrim = true
 	},
 	["widget_mem_bar"] = {