OmniCC

OmniCC

54M Downloads

Is intended that a Cooldown object needs a parent?

millanzarreta opened this issue ยท 5 comments

commented

Hi!

In you code you have somethink like this:

function Display:GetOrCreate(parent)
return displays[parent] or self:Create(parent)
end

function Display:Create(parent)
local display = setmetatable(Addon:CreateHiddenFrame("Frame", nil, parent), Display_MT)

display:SetScript("OnSizeChanged", self.OnSizeChanged)
display.text = display:CreateFontString(nil, "OVERLAY")
display.cooldowns = {}

displays[parent] = display
return display

end

This is called in this function:

local function showTimer(cooldown, duration)
	local minDuration

	local settings = Addon:GetGroupSettingsFor(cooldown)
    if settings and settings.enabled then
		minDuration = settings.minDuration or 0
    else
		minDuration = math.huge
	end

	if (duration or 0) > minDuration then
		if not hooked[cooldown] then
			hooked[cooldown] = true
			cooldown:HookScript("OnHide", cooldown_OnHide)
		end

		Display:GetOrCreate(cooldown:GetParent()):ShowCooldownText(cooldown)
		active[cooldown] = true
	else
		hideTimer(cooldown)
    end
end

If cooldown:GetParent() don't exist a LUA error occurs (in the "displays[parent] = display" line). Some cooldown frames have not parents, speacilly some addon cooldown frames. Is this LUA error intended? In my opinion I think you should consider this possibility.

commented

Its an error that OmniCC attempts to get/create displays for nil parents. Do you have an example addon that has cooldowns without parents?

commented

Yes I have a example, the addon LoseControl that I currently maintain in the version 6.02 and under have this problem. In the new version 6.03 I have created a new auxiliar frames only with the objective of be parent of the cooldowns frames, and the problem is solved.

I don't know if has a error or "bad design" have a Cooldown frames in my addon without other frames as their parents, and don't know if this is frequent on other addons or not. But is true that the old version of OmniCC works well, and the new version don't.

To download the 6.02 version of LoseControl: https://wow.curseforge.com/projects/losecontrol/files/2615610
To test it, after install the addon, go to configuration panel of LoseControl, and select "Uncheck", the Cooldown frames showns and the LUA error triggers.

commented

Try with the latest commit (6b43e46).

OmniCC uses the parent of the object to avoid showing text for multiple cooldowns on the same object.

commented

I've tested it and it seems to work well with this change. Nice!

commented

Fix is implemented in 8.0.5