WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Attempt to find 'this' in non-framescript object? (https://www.wowinterface.com/forums/showthread.php?t=45129)

Coote 11-11-12 10:19 PM

Attempt to find 'this' in non-framescript object?
 
I'm getting a really funky error with ncHoverBind when attempting to use it with a particular compilation (already notified the person who made it), and wondering if the compatibility issue is with ncHoverBind, or possibly theirs.

I'm well aware that 'this' was removed as a global variable a while back, and ncHoverBind doesn't even use 'this' to begin with.

Here's the error...

Code:

Message: Interface\AddOns\ncHoverBind\ncHoverBind.lua:247: Attempt to find 'this' in non-framescript object
Time: 11/11/12 23:01:33
Count: 4
Stack: [C]: in function `GetObjectType'
Interface\AddOns\ncHoverBind\ncHoverBind.lua:247: in function `register'
Interface\AddOns\ncHoverBind\ncHoverBind.lua:261: in function `?'
Interface\FrameXML\ChatFrame.lua:4358: in function `ChatEdit_ParseText'
Interface\FrameXML\ChatFrame.lua:4052: in function `ChatEdit_SendText'
Interface\FrameXML\ChatFrame.lua:4091: in function `ChatEdit_OnEnterPressed'
[string "*:OnEnterPressed"]:1: in function <[string "*:OnEnterPressed"]:1>

Locals: (*temporary) = <table> {
 1 = <unnamed> {
 }
 2 = <unnamed> {
 }
 3 = <unnamed> {
 }
 4 = <unnamed> {
 }
 0 = <unnamed> {
 }
}

Here's the code blocks containing lines 247 and 260.

(246-257)
Code:

                local function register(val)
                        if val.IsProtected and val.GetObjectType and val.GetScript and val:GetObjectType()=="CheckButton" and val:IsProtected() then
                                local script = val:GetScript("OnClick")
                                if script==button then
                                        val:HookScript("OnEnter", function(self) bind:Update(self) end)
                                elseif script==stance then
                                        val:HookScript("OnEnter", function(self) bind:Update(self, "STANCE") end)
                                elseif script==pet then
                                        val:HookScript("OnEnter", function(self) bind:Update(self, "PET") end)
                                end
                        end
                end

(259-263)
Code:

                local val = EnumerateFrames()
                while val do
                        register(val)
                        val = EnumerateFrames(val)
                end


Phanx 11-11-12 11:40 PM

That error is caused by non-frame tables whose metatable __index is a frame. You can fix it by making your frame check more robust:

Code:

if val.IsProtected
and val.GetObjectType
and val.GetScript
and type(rawget(val, 0)) == "userdata"
and val:GetObjectType() == "CheckButton"
and val:IsProtected() then


Coote 11-11-12 11:52 PM

Thanks for that, but still a no go. It just throws an error at the second code snippet I pasted in above.

Code:

Message: Interface\AddOns\ncHoverBind\ncHoverBind.lua:262: EnumerateFrames: Couldn't find 'this' in current object
Time: 11/12/12 00:49:02
Count: 1
Stack: [C]: in function `EnumerateFrames'
Interface\AddOns\ncHoverBind\ncHoverBind.lua:262: in function `?'
Interface\FrameXML\ChatFrame.lua:4358: in function `ChatEdit_ParseText'
Interface\FrameXML\ChatFrame.lua:4052: in function `ChatEdit_SendText'
Interface\FrameXML\ChatFrame.lua:4091: in function `ChatEdit_OnEnterPressed'
[string "*:OnEnterPressed"]:1: in function <[string "*:OnEnterPressed"]:1>

Locals: (*temporary) = <table> {
 1 = <unnamed> {
 }
 2 = <unnamed> {
 }
 3 = <unnamed> {
 }
 4 = <unnamed> {
 }
 0 = <unnamed> {
 }
}

If it helps any, this error only pops its ugly head with SnailUI. ncHoverBind plays nicely with everything else I've tested it with since MOP released.

Phanx 11-12-12 12:51 AM

You need to also make sure you don't pass non-frame values back into EnumerateFrames. This is probably the easiest way to do it:

Code:

                local function register(val)
                        if val.IsProtected and val.GetObjectType and val.GetScript and type(rawget(val, 0)) == "userdata" and val:GetObjectType()=="CheckButton" and val:IsProtected() then
                                local script = val:GetScript("OnClick")
                                if script==button then
                                        val:HookScript("OnEnter", function(self) bind:Update(self) end)
                                elseif script==stance then
                                        val:HookScript("OnEnter", function(self) bind:Update(self, "STANCE") end)
                                elseif script==pet then
                                        val:HookScript("OnEnter", function(self) bind:Update(self, "PET") end)
                                end
                                return true
                        end
                end

Code:

                local val = EnumerateFrames()
                while val do
                        if register(val) then
                                val = EnumerateFrames(val)
                        end
                end


Coote 11-12-12 12:59 AM

Even worse yet. Those changes cause the game client to crash.

SDPhantom 11-12-12 02:50 AM

Quote:

Originally Posted by Phanx (Post 268742)
Code:

                local val = EnumerateFrames()
                while val do
                        if register(val) then
                                val = EnumerateFrames(val)
                        end
                end


If register(val) ever returns false or nil, this will send the game into an infinite loop.



Try this with Phanx's other modification to register():
Code:

        local val = EnumerateFrames()
        while val and register(val) do
                val = EnumerateFrames(val)
        end

The only problem with this is when it runs into the error, it'll stop hooking. There isn't any other way around this.

Dridzt 11-12-12 03:29 AM

You just made friends with Blizzard's broken taintLog tracking, say "hi" :p

/console taintLog 0 and see if the error disappears.

Edit: If you verify that the broken taint log mechanism is at fault you can workaround it by going through both your addons and finding any global frames that are unassigned local references and make sure they're assigned to a local variable.

Coote 11-12-12 04:54 AM

That mostly works. No errors, and the binding confirmation pops up. Though, the issue now, after testing it, is binding no longer works with any of these changes.

I've reverted all these changes, and I guess I'll just use a different bar mod rather than trying to get it to play nicely with SnailUI for now.

Phanx 11-12-12 05:06 AM

Well, the best solution to the problem would really be to figure out which addon is screwing with frame metatables and get its author to fix the problem.

Coote 11-12-12 05:21 AM

Quote:

Originally Posted by Phanx (Post 268757)
Well, the best solution to the problem would really be to figure out which addon is screwing with frame metatables and get its author to fix the problem.

I believe I've narrowed it down to the ActionBar module in SnailUI, and I've contacted the author. I posted this in the chance it may have been my addon, and in hopes there may have been a workaround on my end to get it working properly.

Thanks for the help, and even though it didn't amount to a whole lot in the end run, you guys still rock. :)


All times are GMT -6. The time now is 03:19 PM.

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