WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   SetPoint() causing taint (https://www.wowinterface.com/forums/showthread.php?t=52944)

jostor 12-02-15 05:24 AM

SetPoint() causing taint
 
Hello there, I'm having a problem with my addon causing a taint. I know in many cases the taint don't come from the addon that is "blamed" for it, but according to the person reporting it (I can't reproduce it myself) it occurs with only my addon and the default UI.

I am using the function SetPoint like for example this:

Code:

frame:SetPoint("TOPLEFT", config, 10, -28)
Where the frame is either a frame created by CreateFrame with types like "Check Button", "Button" (a dropdown) and "EditBox", or a text created with frame:CreateFontString().

All this is done in a function called as a result of PLAYER_LOGIN firing, I also tried with ADDON_LOADED and the same error is happening.

I know these taints are tricky and sometimes hard to figure out, but after trying a lot I simply can't figure out why it would happen in this case. Any ideas? What could I be doing wrong?

MunkDev 12-02-15 05:35 AM

Inb4 Phanx angry post about showing your actual code; show your actual code!
Setting a point like this does not cause execution taint to spread.
I anchor frames on to secure stuff all the time and it has never caused an issue.

Dridzt 12-02-15 05:35 AM

Is your frame trying to take secure or protected (requires a hardware event) actions?

Is it a parent or otherwise related to such a frame?

SetPoint() will cause taint-related errors (100% of addon code causes taint but not all taint is problematic) by design as it could be used to create a "smart button" otherwise (same with hide/show/scale)

In some cases all you'll need to do is wrap your frame movement / show / hide / scale code in a combat check and make sure you never try to take those actions while in combat.

In some cases that is not enough (when taint spreads to a secured Blizzard codepath and causes it to error further down the road)

You need to at least point out your specific addon and code for anyone to offer an opinion really ;)

jostor 12-02-15 08:04 AM

I'll provide some more context:

Code:

local config = CreateFrame("Frame")
This is how the config frame is created, this happens in the code outside of any function (in other words called as soon as the file starts executing)

The following then runs on PLAYER_LOGIN: (edited down slightly, just removing some code which is completely duplicate aside from some variable names and coordinates)
Code:

        config.title = config:CreateFontString("AIconfigTitleFont", "ARTWORK", "GameFontNormal")
        config.title:SetFont(GameFontNormal:GetFont(), 16, "OUTLINE")
        config.title:SetPoint("TOPLEFT", config, 10, -10)
        config.title:SetText(config.name)

        config.enablebox = CreateFrame("CheckButton", "AIenableButton", config, "InterfaceOptionsCheckButtonTemplate")
        config.enablebox:SetPoint("TOPLEFT", config, 10, -28)
        config.enablebox:SetChecked(options.enabled)
        config.enablebox:SetHitRectInsets(0, -200, 0, 0)
        config.enableboxtitle = config:CreateFontString("AIconfigEnableboxFont", "ARTWORK", "GameFontNormal")
        config.enableboxtitle:SetFont(GameFontNormal:GetFont(), 12, "OUTLINE")
        config.enableboxtitle:SetPoint("LEFT", config.enablebox, 30, 0)
        config.enableboxtitle:SetText("|cffffffff" .. L.enable_addon .. "|r")


        config.raidbox = CreateFrame("CheckButton", "AIraidButton", config, "InterfaceOptionsCheckButtonTemplate")
        config.raidbox:SetPoint("TOPLEFT", config, 10, -68)
        config.raidbox:SetChecked(options.inRaid)
        config.raidbox:SetHitRectInsets(0, -200, 0, 0)
        config.raidboxtitle = config:CreateFontString("AIconfigraidboxFont", "ARTWORK", "GameFontNormal")
        config.raidboxtitle:SetFont(GameFontNormal:GetFont(), 12, "OUTLINE")
        config.raidboxtitle:SetPoint("LEFT", config.raidbox, 30, 0)
        config.raidboxtitle:SetText("|cffffffff" .. L.active_raid .. "|r")


        config.channeltitle = config:CreateFontString("AIconfigchanneltitleFont", "ARTWORK", "GameFontNormal")
        config.channeltitle:SetFont(GameFontNormal:GetFont(), 12, "OUTLINE")
        config.channeltitle:SetPoint("TOPLEFT", config, 10, -233)
        config.channeltitle:SetText("|cffffffff" .. L.channel .. "|r")

        config.channeldropdown = CreateFrame("Button", "AIchannelDropdown", config, "UIDropDownMenuTemplate")
        config.channeldropdown:SetPoint("TOPLEFT", config, 10, -253)

        UIDropDownMenu_Initialize(config.channeldropdown, function(self, level) 
                local info = UIDropDownMenu_CreateInfo()
                local channelOptions = {
                        L.channel_say,
                        L.channel_raid,
                        L.channel_party,
                        L.channel_instance,
                        L.channel_yell,
                        L.channel_self,
                        L.channel_emote,
                        L.channel_whisper,
                        L.channel_custom
                }
                for k,v in pairs(channelOptions) do
                        info = UIDropDownMenu_CreateInfo()
                        info.text = v
                        info.value = v
                        info.func = function(self) UIDropDownMenu_SetSelectedID(config.channeldropdown, self:GetID()) if self:GetID() < 8 then config.channelextrabox:Hide() else config.channelextrabox:Show() end end
                        UIDropDownMenu_AddButton(info, level)
                end
        end)
        UIDropDownMenu_SetSelectedID(config.channeldropdown, selectIdFromChannelName(options.channel))

        config.channelextrabox = CreateFrame("EditBox", "AIextrachannelbox", config.channeldropdown, "InputBoxTemplate")
        config.channelextrabox:SetPoint("RIGHT", 250, 2)
        config.channelextrabox:SetSize(130, 25)
        config.channelextrabox:SetAutoFocus(false)
        config.channelextrabox:SetScript("OnEnterPressed", function(self) self:ClearFocus() end)
        if UIDropDownMenu_GetSelectedID(config.channeldropdown) < 7 then
                config.channelextrabox:Hide()
        end
        config.channelextrabox:SetText(options.channelExtra)
        config.channelextrabox:SetCursorPosition(0)


        config.smartbox = CreateFrame("CheckButton", "AIsmartChannelButton", config, "InterfaceOptionsCheckButtonTemplate")
        config.smartbox:SetPoint("TOPLEFT", config, 10, -283)
        config.smartbox:SetChecked(options.smartChannel)
        config.smartbox:SetHitRectInsets(0, -200, 0, 0)

        config.smartbox:SetScript("OnEnter", function(self) 
                GameTooltip:SetOwner(self, "ANCHOR_TOPLEFT", 0, 0)
                GameTooltip:SetText(L.smart_channel)
                GameTooltip:AddLine(L.smart_details, 1, 1, 1)
               
                GameTooltip:Show()
        end)

        config.smartbox:SetScript("OnLeave", function(self) GameTooltip:Hide() end)


        config.smartboxtitle = config:CreateFontString("AIconfigsmartboxFont", "ARTWORK", "GameFontNormal")
        config.smartboxtitle:SetFont(GameFontNormal:GetFont(), 12, "OUTLINE")
        config.smartboxtitle:SetPoint("LEFT", config.smartbox, 30, 0)
        config.smartboxtitle:SetText("|cffffffff" .. L.smart_channel .. "|r")

Config itself is added to Interface options with
Code:

InterfaceOptions_AddCategory(config)
This code is causing SetPoint() to be tainted which later causes problem for this user with the built-in raidframes as those also use the SetPoint() function.

All the code I posted runs when the player logs in, so it should not be in combat, and even if it is, doing this should still be okay in combat, as I am not modifying any frames depending on something happening in combat?

Resike 12-02-15 09:32 AM

This calls cause a taint for sure, then it spreads to any dropdown, when it reaches a protected frame with a dropdown then you get the error:

UIDropDownMenu_SetSelectedName, UIDropDownMenu_SetSelectedValue, UIDropDownMenu_SetSelectedID

You can read more here:

http://www.wowinterface.com/forums/s...t=taint+thread

MunkDev 12-02-15 09:44 AM

Example of dropdown that doesn't spread taint:
Lua Code:
  1. local dropdown = CreateFrame("Button", "TestDropdown", parent, "UIDropDownMenuTemplate")
  2. dropdown.text = _G["TestDropdownText"]
  3. dropdown.text:SetText("Default text")
  4. dropdown.info = {}
  5. dropdown.initialize = function(self)
  6.     wipe(self.info)
  7.     for key, value in pairs(dataTable) do
  8.         self.info.text = key
  9.         self.info.value = value
  10.         self.info.func = function(item)
  11.             self.selectedID = item:GetID()
  12.             self.text:SetText(key)
  13.             self.value = value
  14.         end
  15.         self.info.checked = key == self.text:GetText()
  16.         UIDropDownMenu_AddButton(self.info, 1)
  17.     end
  18. end
  19.  
  20. -- get value from dropdown.value

Resike 12-02-15 10:13 AM

Quote:

Originally Posted by MunkDev (Post 312107)
Example of dropdown that doesn't spread taint:
Lua Code:
  1. local dropdown = CreateFrame("Button", "TestDropdown", parent, "UIDropDownMenuTemplate")
  2. dropdown.text = _G["TestDropdownText"]
  3. dropdown.text:SetText("Default text")
  4. dropdown.info = {}
  5. dropdown.initialize = function(self)
  6.     wipe(self.info)
  7.     for key, value in pairs(dataTable) do
  8.         self.info.text = key
  9.         self.info.value = value
  10.         self.info.func = function(item)
  11.             self.selectedID = item:GetID()
  12.             self.text:SetText(key)
  13.             self.value = value
  14.         end
  15.         self.info.checked = key == self.text:GetText()
  16.         UIDropDownMenu_AddButton(self.info, 1)
  17.     end
  18. end
  19.  
  20. -- get value from dropdown.value

What would dataTable be here?

MunkDev 12-02-15 10:24 AM

Quote:

Originally Posted by Resike (Post 312109)
What would dataTable be here?

The table used to generate entries on the dropdown.
You can't run this snippet as is. It's just a template.

jostor 12-02-15 11:50 AM

Thanks, I'll try to change the dropdown like you suggested and see if makes a difference.

jostor 12-04-15 02:15 AM

It was indeed my dropdown that was causing the issue. Thanks, I'll be more careful with them in the future!


All times are GMT -6. The time now is 04:06 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI