WoW BlueTracker Home | RSS | News | Contact
Recent | Search | Archive | CS Posts
Poster: Itchyban at 5/20/2005 11:43:10 PM PDT
Subject: [BUG] Hide() and OnLeave Cause C Race/Failure
   Desired behavior:

* Mouse leaves frame, frame hides
* Click on frame, (do stuff), frame hides

Approach:

* Create a Button (since I never seem to be able to get a Frame to respond to clicks), RegisterForClicks in OnLoad

- OnClick -- calls button:Hide()

- OnLeave -- calls button:Hide()

Observed behavior:

* Show() the frame, it renders
* Move mouse over frame, you get entering message
* Take one of the following actions:
- Mouse leaves frame, frame hides
- Click on frame, "C stack overflow" repeatedly calling button:Hide() with the line in question reported as being in the OnClick handler.

HF: OnClick LeftButton
ClickOut left clicked
Clickout hide
OnLeave (repeating until the C stack overflows)



Removing the OnLeave handler's button:Hide() call resolves the crash, but still does not have expected behavior:

HF: OnClick LeftButton
ClickOut left clicked
Clickout hide
OnLeave
OnLeave Exit
OnLeave
OnLeave Exit
OnClick, after callback




Apparently, calling Hide() on a frame with an OnLeave handler is a very bad thing. (I have similar behavior in other situations as well. This is a "minimal" case for demonstration.)

I suspect that the Lua OnLeave handler is being called before the frame is internally tagged as not visible. It would explain the behavior if the internal code looked something like

if ( this.internals.state.isvisible ) then
this.internals.methods.onleave()
/* do more cleanup */
end
/* do more stuff */
this.internals.state.isvisible = 0;

When I was checking, IsVisible() returned 1 on calls to OnLeave and "protecting" the OnLeave :Hide() with a visibiity check does not resolve the issue.

This is not only problematic for this case, but inconsistent with "normal" OnLeave behavior, where OnLeave is not called until after the mouse has left the confines of the frame.


(Yes, I can probably "work around" this apparent bug by temporarily disabling the OnLeave handler. However, there looks to be something amiss in the logic within the C code calling these handlers.)


Example code (with or without the IsVisible() check, this fails)


COL = {};

local function print(str)
table.insert(COL, str);
end

----------------------
--- ClickoutFrame ---
----------------------

---
--- ClickOutFrame_OnClick
---

function ClickOutFrame_OnClick (button)
print ("HF: OnClick "..button);

if ( button == "LeftButton" ) then

print("ClickOut left clicked");

-- if ( ClickOutFrame:IsVisible() ) then
print("Clickout hide");
ClickOutFrame:Hide();
-- end

print("OnClick, after callback")

elseif ( button == "RightButton" ) then
print("Right mouse click");

end

end



---
--- ClickOutFrame_OnLeave
---

function ClickOutFrame_OnLeave ()
print ("OnLeave");
ClickOutFrame:Hide();
print ("OnLeave Exit");
end



<Ui xmlns="http://www.blizzard.com/wow/ui/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ../../FrameXML/UI.xsd">

<Script file="ClickOut.lua"/>

<Button name="ClickOutFrame"
toplevel="true"
frameStrata="DIALOG"
enableMouse="true"
hidden="true"
parent="UIParent">
<Size>
<AbsDimension x="200" y="200"/>
</Size>

<Anchors>
<Anchor point="CENTER">
<Offset>
<AbsDimension x="0" y="0"/>
</Offset>
</Anchor>
</Anchors>

<Layers>
<Layer level="ARTWORK">

<Texture name="ClickOutFrame_Fill"
setAllPoints="true">
<Size>
<AbsDimension x="10" y="10"/>
</Size>
<Color r="1" g="1" b="1"/>
</Texture>
</Layer>
</Layers>

<Scripts>
<OnLoad>
this:RegisterForClicks("LeftButtonUp", "RightButtonUp");
</OnLoad>

<OnClick>
DEFAULT_CHAT_FRAME:AddMessage("HF: OnClick");
ClickOutFrame_OnClick(arg1);
</OnClick>

<OnEnter>
DEFAULT_CHAT_FRAME:AddMessage("HF: Mouse enter");
</OnEnter>

<OnLeave>
ClickOutFrame_OnLeave();
</OnLeave>
</Scripts>
</Button>
</Ui>

[ post edited by Itchyban ]


Yes, one and the same from Veeshan.
  http://forums.worldofwarcraft.com/thread.aspx?fn=wow-interface-customization&t=140628&p=#post140628
 
Poster: slouken at 5/23/2005 1:47:46 PM PDT
Subject: Re: [BUG] Hide() and OnLeave Cause C Race/Fai
   This will be fixed in the 1.5 release patch. (Possibly in the next test server update as well)

[ post edited by slouken ]

  http://forums.worldofwarcraft.com/thread.aspx?fn=wow-interface-customization&t=140628&p=#post142191

View all recent official Blue Posts

WoW Blue Tracker: Archiving World of Warcraft Blue Posts
since March 2005
Home | RSS | News | Contact
Recent | Search | Archive | CS Posts
 

Why Ads?