WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Mysterious taint for changing a drop down selection? (https://www.wowinterface.com/forums/showthread.php?t=58467)

LudiusMaximus 12-17-20 06:55 PM

Mysterious taint for changing a drop down selection?
 
Hi,

my addon DynamicCam is almost useless without the ActionCam. The newly introduced accessibility feature "keep character centered" disables the ActionCam, so I want to prevent users from enabling it. However, I want to inform users what is happening, which is why I modified the Interface->Accessibility->Motion Sickness drop down like this.
(This is just the front end part of my solution, I am changing the cvars with another hook, which however is not required to reproduce the error I am getting.)

Lua Code:
  1. -- Automatically set the dropdown list to an allowed value.
  2. hooksecurefunc("UIDropDownMenu_SetSelectedValue", function(menu, value)
  3.   if menu == InterfaceOptionsAccessibilityPanelMotionSicknessDropdown then
  4.    
  5.     if value == 1 then
  6.  
  7.       print("Debug: 1 not allowed, switching to 4...")
  8.       InterfaceOptionsAccessibilityPanelMotionSicknessDropdown.value = 4
  9.       InterfaceOptionsAccessibilityPanelMotionSicknessDropdown.selectedValue = 4
  10.  
  11.     elseif value == 3 then
  12.  
  13.       print("Debug: 3 not allowed, switching to 2...")
  14.       InterfaceOptionsAccessibilityPanelMotionSicknessDropdown.value = 2
  15.       InterfaceOptionsAccessibilityPanelMotionSicknessDropdown.selectedValue = 2
  16.  
  17.     end
  18.    
  19.   end
  20. end)

I also used UIDropDownMenu_SetSelectedValue() to set the values before, but because of the strange error I am experiencing I switched to just setting value and selectedValue; but the error remains. Here is how to reproduce it:
  1. Go into combat.
  2. Open the game menu (click the button, do not press ESC which would exit combat).
  3. Click on "Interface".
  4. Chose the "Accessibilty" tab of the "Interface" window.
  5. Click the "Motion Sickness" dropdown.
  6. Select one of the two options including "Keep Character Centered" (observe that it is automatically changed as expected).
  7. Click the "Motion Sickness" dropdown again!
  8. Select any option!
  9. Press the "Cancel" button in the bottom right of the "Interface" window.

You now get an "Interface action failed because of an AddOn" error.
With BugSack I was able to identify what's happening:

Code:

[ADDON_ACTION_BLOCKED] AddOn 'MinimalWorkingExample' tried to call the protected function 'CompactRaidFrameContainer:Hide()'.
[string "@!BugGrabber\BugGrabber.lua"]:519: in function <!BugGrabber\BugGrabber.lua:519>
[string "=[C]"]: in function `Hide'
[string "@Blizzard_CompactRaidFrames\Blizzard_CompactRaidFrameManager.lua"]:530: in function `CompactRaidFrameManager_UpdateContainerVisibility'
[string "@Blizzard_CompactRaidFrames\Blizzard_CompactRaidFrameManager.lua"]:475: in function <...mpactRaidFrames\Blizzard_CompactRaidFrameManager.lua:464>
[string "@Blizzard_CompactRaidFrames\Blizzard_CompactRaidFrameManager.lua"]:514: in function `CompactRaidFrameManager_SetSetting'
[string "@Blizzard_CUFProfiles\Blizzard_CompactUnitFrameProfiles.lua"]:594: in function `func'
[string "@Blizzard_CUFProfiles\Blizzard_CompactUnitFrameProfiles.lua"]:571: in function `CompactUnitFrameProfiles_ApplyProfile'
[string "@Blizzard_CUFProfiles\Blizzard_CompactUnitFrameProfiles.lua"]:174: in function `CompactUnitFrameProfiles_ApplyCurrentSettings'
[string "@Blizzard_CUFProfiles\Blizzard_CompactUnitFrameProfiles.lua"]:83: in function `CompactUnitFrameProfiles_CancelChanges'
[string "@Blizzard_CUFProfiles\Blizzard_CompactUnitFrameProfiles.lua"]:76: in function <...rd_CUFProfiles\Blizzard_CompactUnitFrameProfiles.lua:74>
[string "=[C]"]: in function `pcall'
[string "@FrameXML\InterfaceOptionsFrame.lua"]:215: in function <FrameXML\InterfaceOptionsFrame.lua:214>
[string "=[C]"]: ?
[string "@FrameXML\InterfaceOptionsFrame.lua"]:250: in function <FrameXML\InterfaceOptionsFrame.lua:246>

So it all starts with InterfaceOptionsFrameCancel_OnClick() and eventually tries to hide CompactRaidFrameContainer, which is apparently protected in combat.


I would have many questions regarding this:
  1. I always thought taint is only created when an addon calls functions. But apparently it is also created by just assigning variables?
  2. How is the taint passed on in this case? It is not my addon calling InterfaceOptionsFrameCancel_OnClick().
  3. Why are steps 7. and 8. in my description to reproduce the error even necessary?
  4. If there is no solution to this taint problem, maybe somebody has a better idea to achieve what I initially wanted?

Thank you all in advance!

MunkDev 12-17-20 11:57 PM

https://www.wowinterface.com/forums/...019#post336019

LudiusMaximus 12-18-20 11:47 AM

Thanks! This explains a lot, but it also seems like there is not much I can do to resolve this. Maybe I can hide the drop down and replace it with my own. Will give this a try.

MunkDev 12-18-20 04:49 PM

Maybe, or just put a big red warning label next to it.

LudiusMaximus 12-19-20 12:03 PM

All right, I built my own drop down list, hoping that I can use this without spreading taint.

But it turns out that even this miminal example spreads the taint:

Lua Code:
  1. local myDropdown = CreateFrame("Frame", "myDropdown", UIParent, "UIDropDownMenuTemplate")
  2. myDropdown:SetPoint("TOP")
  3. UIDropDownMenu_SetWidth(myDropdown, 130)
  4.  
  5. local function MyDropdown_Initialize()
  6.  
  7.   local info = UIDropDownMenu_CreateInfo()
  8.  
  9.   info.text = "test"
  10.   info.value = 1
  11.   UIDropDownMenu_AddButton(info)
  12.  
  13.   info.value = 2
  14.   UIDropDownMenu_AddButton(info)
  15.  
  16.   info.value = 3
  17.   UIDropDownMenu_AddButton(info)
  18.  
  19.   info.value = 4
  20.   info.checked = true
  21.   UIDropDownMenu_AddButton(info)
  22.  
  23. end
  24.  
  25. UIDropDownMenu_Initialize(myDropdown, MyDropdown_Initialize)


You get the error like this:
  1. Go into combat.
  2. Open the game menu (click the button, do not press ESC which would exit combat).
  3. Click on "Interface".
  4. Chose the "Accessibilty" tab of the "Interface" window.
  5. Click my drop down menu at the top of the (UIParent) screen.
  6. Click the "Cancel" button in the bottom right of the "Interface" window.

Is this bugged or am I doing anything wrong?

LudiusMaximus 12-23-20 03:58 AM

I think I got it working now.

Made my own local copy of UIDropDownMenu_AddButton()
and found out that the taint is not spread if I remove the line
Code:

button.checked = info.checked;


All times are GMT -6. The time now is 02:55 PM.

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