View Single Post
10-15-13, 06:15 PM   #1
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
Fix Wrapped_OnLeave in SecureHandlers.lua

Wrapped_OnLeave will only work for the most recent wrap due to:
Code:
	if ( motion and self:GetAttribute("_wrapentered")) then
		self:SetAttribute("_wrapentered", nil);
That prevents any further wraps from running. A simple fix is:
Code:
local function Wrapped_OnLeave(self, header, preBody, postBody, wrap,
                               motion, ...)
    local allow, message;
    if ( motion and self:GetAttribute("_wrapentered")) then
        if ( IsWrapEligible(self) ) then
            allow, message =
                SecureHandler_Other_Execute(header, self, "self",
                                            preBody);
            if (allow == false) then
                self:SetAttribute("_wrapentered", nil);
                return;
            end
        end
    end

    securecall(SafeCallWrappedHandler, self, wrap, motion, ...);
    self:SetAttribute("_wrapentered", nil);

    if (postBody and message ~= nil) then
        SecureHandler_Other_Execute(header, self, "self,message",
                                    postBody, message);
    end
end
However, I'm not even sure why the _wrapentered check is even needed. The motion argument already ensures that it was a hardware event. I thought it might be to ensure an OnLeave for every OnEnter, but OnEnter can trigger multiple time without a corresponding OnLeave so that can't be it.

If anything I think the _wrapentered should be scrapped and maybe a check added if motion isn't set to see if the frame that caused the focus loss was secure and still allow the script to run.
  Reply With Quote