Thread Tools Display Modes
10-22-14, 12:22 PM   #1
Mr.Dio
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 5
Exclamation AddOn tried to call the protected function

Hello! I need help with the solution of a problem in addon NiceColorize. I start boss fight and get error:
Code:
AddOn "NiceColorize" tried to call the protected function "Boss2TargetFrame:Hide()".
I've tried to remove all references to the bossframe in addon, but it did not produce results. Tell me how to fix this problem. Thx!
*translated using Google Translate

------------

Всем привет! Не могу найти решения проблемы с аддоном NiceColorize. Когда я начинаю биться с боссом то появляется ошибка:
Code:
Аддон "NiceColorize" пытался вызвать защищенную функцию "Boss2TargetFrame:Hide()"
Вот только в коде аддона, у меня нет упоминания этой функции. Я уже пытался убирать все упоминания о фреймахбосса, но это не дало результатов. Помогите решить данную проблему!
  Reply With Quote
10-22-14, 09:04 PM   #2
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
The problem with taint is, that the error message doesn't always shows the actual cause of the taint. It shows the first action that a tainted frame/code is trying to do after it was tainted (by your code or the code of other addons). :/ (even if it says "AddOn "NiceColorize" tried to ...")

So "Boss2TargetFrame:Hide()" doesn't has to be in your code. It's just an action that Blizzards boss frame executes after it was tainted.

On a quick view I'm seeing that you're doing a lot of stuff with several unit frames at OnUpdate (in combat too). I can't test your addon as I don't have access to any boss fights. But you could try "/console taintlog" and review \World of Warcraft\Logs\taint.log as a first step to see what's actually going on.

On a side note: you're doing a lot of things ao every OnUpdate. I did no measurement, but the client feels kind of laggy with your addon loaded. You should at least restict that to a few times/s or choose an other approach.

Last edited by Duugu : 10-22-14 at 10:45 PM.
  Reply With Quote
10-23-14, 08:27 PM   #3
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Instead of coloring 1000 things in every OnUpdate, you should find the functions where the default UI colors each thing, and hook those functions, so you only run the parts of your code that are needed to color each thing when you actually need to change the color of that thing.

This will also let you use secure hooks (hooksecurefunc or <frame>:HookScript) so you don't cause taint.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
10-25-14, 08:26 AM   #4
Mr.Dio
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 5
I use this code
Code:
	hooksecurefunc("PartyMemberFrame_UpdateMember", function()
		for i, PF in pairs({PartyMemberFrame1, PartyMemberFrame2, PartyMemberFrame3, PartyMemberFrame4}) do
			if PF:IsShown() then
				if UnitIsPlayer("party"..i) then
							local C = RAID_CLASS_COLORS[select(2, UnitClass("party"..i))]

					if C then
						_G["PartyMemberFrame"..i.."Name"]:SetTextColor(C.r, C.g, C.b)
					end
					else
					_G["PartyMemberFrame"..i.."Name"]:SetTextColor(1, 0.8, 0)
				end
				_G["PartyMemberFrame"..i.."Name"]:SetText(GetUnitName("party"..i, false))
				_G["PartyMemberFrame"..i.."Name"]:SetFont(DefaultFont, DefaultSize, "OUTLINE")
			end
		end
	end)
but still get taint error
Code:
10/25 18:18:32.140  Interface\FrameXML\UnitFrame.lua:181 UnitFrame_OnEvent()
10/25 18:18:32.140  An action was blocked in combat because of taint from NiceColorize - PartyMemberFrame2PetFrame:Show()
10/25 18:18:32.140      Interface\FrameXML\PartyMemberFrame.lua:176 PartyMemberFrame_UpdatePet()
10/25 18:18:32.140      Interface\FrameXML\PartyMemberFrame.lua:400 PartyMemberFrame_OnEvent()
10/25 18:18:32.140      *:OnEvent:1 PartyMemberFrame2:OnEvent()
10/25 18:18:32.140      Interface\FrameXML\UnitFrame.lua:676
  Reply With Quote
10-25-14, 08:44 AM   #5
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
I don't see anything obviously tainting in that code, but based on your taint log, that's not all of your code.

However, that's not a very efficient use of a function hook. The function you're hooking tells you which frame it updated, so when your hook runs, you only need to update that frame, not every frame.

Code:
hooksecurefunc("PartyMemberFrame_UpdateMember", function(self)
	if self:IsShown() then
		local unit = "party"..self:GetID()
		if UnitIsPlayer(unit) then
			local _, class = UnitClass(unit)
			local color = class and RAID_CLASS_COLORS[class]
			if color then
				self.name:SetTextColor(color.r, color.g, color.b)
			else
				self.name:SetTextColor(1, 0.8, 0)
			end
			self.name:SetText(GetUnitName(unit, false))
		end
	end
end)
You also only need to update things that the default UI actually changes. It will never change the font during gameplay, so you don't need to re-set the font over and over. Just do that one time when your addon loads:

Code:
for i = 1, 4 do
	_G["PartyMemberFrame"..i.."Name"]:SetFont(DefaultFont, DefaultSize, "OUTLINE")
end
Try commenting out all of your code, and re-working one part at a time. Make sure each part is taint-free before re-introducing the next part.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » AddOn tried to call the protected function


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off