Thread Tools Display Modes
02-16-10, 12:33 AM   #1
nightcracker
A Molten Giant
 
nightcracker's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 716
Crash on LFD zoning

Hi all!

For my ncUI I skin/modify my chat frames with the below script. The problem is, if I use the LFD feature and try to enter the instance the game freeezes on the loading bar. Because it freezes on the loading bar there is no error report so I have no idea what the problem is. If I don't use my chat script there is no problem. The problem lies in this script file, please help me find out where.

lua Code:
  1. local hooks = {}
  2. local dummy = function() end
  3. local db = ncUIdb["chat"]
  4.  
  5. local function addmessage(frame, text, red, green, blue, id)
  6.     text = tostring(text) or ""
  7.     for k,v in pairs(db.replaces) do
  8.         text = text:gsub("|h%["..k.."%]|h", "|h"..v.."|h")
  9.     end
  10.     text = text:gsub("|h%[(%d+)%. .-%]|h", "|h%1|h")
  11.     text = text:gsub("(|Hplayer.-|h)%[(.-)%]|h", "%1%2|h")
  12.     text = text:gsub(" says:", ":")
  13.     text = text:gsub(" whispers:", " <")
  14.     text = text:gsub("To (|Hplayer.+|h):", "%1 >")
  15.     text = text:gsub("(|Hplayer.+|h) has earned the achievement (.+)!", "%1 ! %2")
  16.     return hooks[frame](frame, text, red, green, blue, id)
  17. end
  18.  
  19. local function hideframe(f)
  20.     f.Show = dummy
  21.     f:Hide()
  22. end
  23.  
  24. local x=({ChatFrameEditBox:GetRegions()})
  25. x[6]:SetAlpha(0)
  26. x[7]:SetAlpha(0)
  27. x[8]:SetAlpha(0)
  28. ChatFrameEditBox:SetAltArrowKeyMode(nil)
  29. ChatFrameEditBox:ClearAllPoints()
  30. ChatFrameEditBox:SetPoint("TOPLEFT", ChatFrameEditBoxBackground)
  31. ChatFrameEditBox:SetPoint("BOTTOMRIGHT", ChatFrameEditBoxBackground)
  32.  
  33. local function enter()
  34.     for i=1,NUM_CHAT_WINDOWS do
  35.         local f = _G["ChatFrame"..i]
  36.         hideframe(_G["ChatFrame"..i.."UpButton"])
  37.         hideframe(_G["ChatFrame"..i.."DownButton"])
  38.         hideframe(_G["ChatFrame"..i.."BottomButton"])
  39.         f:SetFading(false)
  40.         f:EnableMouseWheel(true)
  41.             _G["ChatFrame"..i]:SetUserPlaced(true)
  42.         f:SetScript("OnMouseWheel", function(frame, delta)
  43.             if delta > 0 and IsShiftKeyDown() then
  44.                 frame:ScrollToTop()
  45.             elseif delta > 0 then
  46.                 frame:ScrollUp()
  47.             elseif delta < 0 and IsShiftKeyDown() then
  48.                 frame:ScrollToBottom()
  49.             else
  50.                 frame:ScrollDown()
  51.             end
  52.         end)
  53.         hooks[f] = f.AddMessage
  54.         f.AddMessage = addmessage
  55.     end
  56.     FCF_ResetChatWindows() 
  57.     ToggleChatColorNamesByClassGroup(true, "SAY")
  58.     ToggleChatColorNamesByClassGroup(true, "EMOTE")
  59.     ToggleChatColorNamesByClassGroup(true, "YELL")
  60.     ToggleChatColorNamesByClassGroup(true, "GUILD")
  61.     ToggleChatColorNamesByClassGroup(true, "GUILD_OFFICER")
  62.     ToggleChatColorNamesByClassGroup(true, "GUILD_ACHIEVEMENT")
  63.     ToggleChatColorNamesByClassGroup(true, "ACHIEVEMENT")
  64.     ToggleChatColorNamesByClassGroup(true, "WHISPER")
  65.     ToggleChatColorNamesByClassGroup(true, "PARTY")
  66.     ToggleChatColorNamesByClassGroup(true, "PARTY_LEADER")
  67.     ToggleChatColorNamesByClassGroup(true, "RAID")
  68.     ToggleChatColorNamesByClassGroup(true, "RAID_LEADER")
  69.     ToggleChatColorNamesByClassGroup(true, "RAID_WARNING")
  70.     ToggleChatColorNamesByClassGroup(true, "BATTLEGROUND")
  71.     ToggleChatColorNamesByClassGroup(true, "BATTLEGROUND_LEADER")
  72.     ToggleChatColorNamesByClassGroup(true, "CHANNEL1")
  73.     ToggleChatColorNamesByClassGroup(true, "CHANNEL2")
  74.     ToggleChatColorNamesByClassGroup(true, "CHANNEL3")
  75.     ToggleChatColorNamesByClassGroup(true, "CHANNEL4")
  76.     FCF_OpenNewWindow("Whisper")
  77.     FCF_UnDockFrame(ChatFrame3)
  78.     FCF_SetLocked(ChatFrame3, 1)
  79.     ChatFrame3:SetJustifyH("RIGHT")
  80.     ChatFrame3:ClearAllPoints()
  81.     ChatFrame3:SetPoint("TOPRIGHT", CubeRightBG, "TOPLEFT", -8, 0)
  82.     ChatFrame3:SetPoint("BOTTOMLEFT", InfoRight, "TOPLEFT", 0, 10)
  83.     ChatFrame3:Show()
  84.     ChatFrame3Tab:Hide()
  85.     ChatFrame_RemoveAllMessageGroups(ChatFrame3)
  86.     ChatFrame_AddMessageGroup(ChatFrame3, "MONSTER_SAY")
  87.     ChatFrame_AddMessageGroup(ChatFrame3, "MONSTER_EMOTE")
  88.     ChatFrame_AddMessageGroup(ChatFrame3, "MONSTER_YELL")
  89.     ChatFrame_AddMessageGroup(ChatFrame3, "MONSTER_WHISPER")
  90.     ChatFrame_AddMessageGroup(ChatFrame3, "MONSTER_BOSS_EMOTE")
  91.     ChatFrame_AddMessageGroup(ChatFrame3, "MONSTER_BOSS_WHISPER")
  92.     ChatFrame_AddMessageGroup(ChatFrame3, "SYSTEM")
  93.     ChatFrame_AddMessageGroup(ChatFrame3, "ERRORS")
  94.     ChatFrame_AddMessageGroup(ChatFrame3, "AFK")
  95.     ChatFrame_AddMessageGroup(ChatFrame3, "DND")
  96.     ChatFrame_AddMessageGroup(ChatFrame3, "ACHIEVEMENT")
  97.     ChatFrame_AddMessageGroup(ChatFrame3, "COMBAT_XP_GAIN")
  98.     ChatFrame_AddMessageGroup(ChatFrame3, "COMBAT_HONOR_GAIN")
  99.     ChatFrame_AddMessageGroup(ChatFrame3, "COMBAT_FACTION_CHANGE")
  100.     ChatFrame_AddMessageGroup(ChatFrame3, "LOOT")
  101.     ChatFrame_AddMessageGroup(ChatFrame3, "MONEY")
  102.     ChatFrame_RemoveAllMessageGroups(ChatFrame1)
  103.     ChatFrame_AddMessageGroup(ChatFrame1, "SAY")
  104.     ChatFrame_AddMessageGroup(ChatFrame1, "EMOTE")
  105.     ChatFrame_AddMessageGroup(ChatFrame1, "YELL")
  106.     ChatFrame_AddMessageGroup(ChatFrame1, "GUILD")
  107.     ChatFrame_AddMessageGroup(ChatFrame1, "GUILD_OFFICER")
  108.     ChatFrame_AddMessageGroup(ChatFrame1, "GUILD_ACHIEVEMENT")
  109.     ChatFrame_AddMessageGroup(ChatFrame1, "PARTY")
  110.     ChatFrame_AddMessageGroup(ChatFrame1, "PARTY_LEADER")
  111.     ChatFrame_AddMessageGroup(ChatFrame1, "RAID")
  112.     ChatFrame_AddMessageGroup(ChatFrame1, "RAID_LEADER")
  113.     ChatFrame_AddMessageGroup(ChatFrame1, "RAID_WARNING")
  114.     ChatFrame_AddMessageGroup(ChatFrame1, "BATTLEGROUND")
  115.     ChatFrame_AddMessageGroup(ChatFrame1, "BATTLEGROUND_LEADER")
  116.     ChatFrame_AddMessageGroup(ChatFrame1, "BG_HORDE")
  117.     ChatFrame_AddMessageGroup(ChatFrame1, "BG_ALLIANCE")
  118.     ChatFrame_AddMessageGroup(ChatFrame1, "BG_NEUTRAL")
  119.     ChatFrame_AddMessageGroup(ChatFrame3, "WHISPER")
  120.     ChatFrame_AddMessageGroup(ChatFrame3, "IGNORED")
  121.     ChatFrame1:ClearAllPoints()
  122.     ChatFrame1:SetPoint("TOPLEFT", CubeLeftBG, "TOPRIGHT", 8, 0)
  123.     ChatFrame1:SetPoint("BOTTOMRIGHT", InfoLeft, "TOPRIGHT", 0, 10)
  124.     SetCVar("chatLocked", 1)
  125.     hideframe(ChatFrameMenuButton)
  126. end
  127.  
  128. for channel, val in pairs(db.sticky_channels) do
  129.     if val then
  130.         ChatTypeInfo[string.upper(channel)].sticky = 1
  131.     end
  132. end
  133. for i = 1,7 do
  134.     for k,v in pairs(CHAT_FRAME_TEXTURES) do
  135.         _G["ChatFrame"..i..v]:Hide()
  136.     end
  137. end
  138. for k in pairs(CHAT_FRAME_TEXTURES) do
  139.     CHAT_FRAME_TEXTURES[k] = nil
  140. end
  141. local f = CreateFrame("Frame")
  142. f:SetScript("OnEvent", enter)
  143. f:RegisterEvent("PLAYER_ENTERING_WORLD")
  144.  
  145. local function colorborder(r,g,b)
  146.     ChatFrameEditBoxBackground:SetBackdropBorderColor(r,g,b)
  147. end
  148. hooksecurefunc("ChatEdit_UpdateHeader", function()
  149.     local typ = DEFAULT_CHAT_FRAME.editBox:GetAttribute("chatType")
  150.     if (typ == "CHANNEL") then
  151.         local id = GetChannelName(DEFAULT_CHAT_FRAME.editBox:GetAttribute("channelTarget"))
  152.         if id == 0 then
  153.             colorborder(unpack(ncUIdb["chat"].colorscheme_editbox))
  154.         else
  155.             colorborder(ChatTypeInfo[typ..id].r,ChatTypeInfo[typ..id].g,ChatTypeInfo[typ..id].b)
  156.         end
  157.     else
  158.         colorborder(ChatTypeInfo[typ].r,ChatTypeInfo[typ].g,ChatTypeInfo[typ].b)
  159.     end
  160. end)
  161.  
  162. local orig1, orig2 = {}, {}
  163. local GameTooltip = GameTooltip
  164. local function OnHyperlinkEnter(frame, link, ...)
  165.     local linktype = link:match("^([^:]+)") and not link:match("player")
  166.     if linktype then
  167.         GameTooltip:SetOwner(frame, "ANCHOR_NONE")
  168.         GameTooltip:SetHyperlink(link)
  169.         GameTooltip:Show()
  170.         if frame:GetName()=="ChatFrame1" then
  171.             GameTooltip:SetPoint("BOTTOMLEFT", CubeLeftBG, "TOPLEFT", 0, 10)
  172.         else
  173.             GameTooltip:SetPoint("BOTTOMRIGHT", CubeRightBG, "TOPRIGHT", 0, 10)
  174.         end
  175.     end
  176.     if orig1[frame] then return orig1[frame](frame, link, ...) end
  177. end
  178. local function OnHyperlinkLeave(frame, ...)
  179.     GameTooltip:Hide()
  180.     if orig2[frame] then return orig2[frame](frame, ...) end
  181. end
  182. local _G = getfenv(0)
  183. for i=1, NUM_CHAT_WINDOWS do
  184.     local frame = _G["ChatFrame"..i]
  185.     orig1[frame] = frame:GetScript("OnHyperlinkEnter")
  186.     frame:SetScript("OnHyperlinkEnter", OnHyperlinkEnter)
  187.     orig2[frame] = frame:GetScript("OnHyperlinkLeave")
  188.     frame:SetScript("OnHyperlinkLeave", OnHyperlinkLeave)
  189. end
  190. local function CreateCopyFrame()
  191.     local frame = CreateFrame("Frame", "CopyFrame", UIParent)
  192.     ncUIdb:CreatePanel(frame, 700, 190, "CENTER", UIParent, "CENTER", 0 ,0)
  193.     frame:Hide()
  194.     frame:SetFrameStrata("DIALOG")
  195.     local scrollArea = CreateFrame("ScrollFrame", "CopyScroll", frame, "UIPanelScrollFrameTemplate")
  196.     scrollArea:SetPoint("TOPLEFT", frame, "TOPLEFT", 5, -5)
  197.     scrollArea:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -25, 5)
  198.     local editBox = CreateFrame("EditBox", "CopyBox", frame)
  199.     editBox:SetMultiLine(true)
  200.     editBox:SetMaxLetters(999)
  201.     editBox:SetAutoFocus(false)
  202.     editBox:SetFontObject(ChatFontNormal)
  203.     editBox:SetWidth(690)
  204.     editBox:SetHeight(190)
  205.     editBox:HookScript("OnEscapePressed", function(self, key)
  206.         frame:Hide()
  207.     end)
  208.     scrollArea:SetScrollChild(editBox)
  209.     local close = CreateFrame("Button", "CopyCloseButton", frame, "UIPanelCloseButton")
  210.     close:SetPoint("TOPRIGHT", frame, "TOPRIGHT", 6, 30)
  211. end
  212.  
  213. local function GetChatText(id)
  214.     id = (tonumber(id) or 1)
  215.     local cf = _G[format("ChatFrame%d",  id)]
  216.     if id > NUM_CHAT_WINDOWS or id == 0 then
  217.         DEFAULT_CHAT_FRAME:AddMessage("Copy: Invalid Chat Frame ID")
  218.         return
  219.     end
  220.     local _, size = cf:GetFont()
  221.     FCF_SetChatWindowFontSize(cf, cf, 0.01)
  222.     local tab = {}
  223.     local lines = {cf:GetRegions()}
  224.     for i=#lines, 1, -1 do
  225.         if lines[i]:GetObjectType() == "FontString" then
  226.             table.insert(tab, lines[i]:GetText())
  227.         end
  228.     end
  229.     local str = table.concat(tab, "\n")
  230.     FCF_SetChatWindowFontSize(cf, cf, size)
  231.     if not CopyFrame then CreateCopyFrame() end
  232.     CopyFrame:Show()
  233.     CopyBox:SetText(str)
  234.     CopyBox:HighlightText()
  235.     CopyBox:SetFocus()
  236. end
  237.  
  238. SLASH_COPY1 = "/copy"
  239. SlashCmdList["COPY"] = function(id) GetChatText(id) end
  240.  
  241. ChatFrameEditBox:HookScript("OnTextChanged", function(self)
  242.     local text = self:GetText()
  243.     if text:len() < 5 then
  244.         if text:sub(1, 4) == "/tt " then
  245.             local unitname, realm
  246.             unitname, realm = UnitName("target")
  247.             if unitname then unitname = gsub(unitname, " ", "") end
  248.             if unitname and not UnitIsSameServer("player", "target") then
  249.                 unitname = unitname .. "-" .. gsub(realm, " ", "")
  250.             end
  251.             ChatFrame_SendTell((unitname or "Invalid Target"), ChatFrame1)
  252.         end
  253.     end
  254. end)
__________________
Three things are certain,
Death, taxes and site not found,
You, victim of one.
  Reply With Quote
02-16-10, 02:40 AM   #2
nightcracker
A Molten Giant
 
nightcracker's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 716
Update: This bug seems to happen at every instance, not only LFD ones.
__________________
Three things are certain,
Death, taxes and site not found,
You, victim of one.
  Reply With Quote
02-16-10, 05:08 AM   #3
v6o
An Onyxian Warder
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 399
Not sure what's making your game crash but you could always disable parts of it to test.

But a recommendation I have is putting your chat initilization only on cold logins and not PLAYER_ENTERING_WORLD. I mean the parts with ToggleChatColorNamesByClassGroup(true, "SAY") and ChatFrame_AddMessageGroup(ChatFrame3, "IGNORED")
__________________
I stopped playing back World of Warcraft in 2010 and I have no plans on returning.
This is a dead account and if you want to continue any of my addons or make a fork then feel free to do so.
This is your permission slip.

If you need to contact me, do so on Twitter @v6ooo

Best regards, v6.
  Reply With Quote
02-16-10, 05:33 AM   #4
Foxlit
A Warpwood Thunder Caller
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 91
Your AddMessage hook causes an infinite tail-call loop.
__________________
... and you do get used to it, after a while.
  Reply With Quote
02-16-10, 07:38 AM   #5
nightcracker
A Molten Giant
 
nightcracker's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 716
Originally Posted by Foxlit View Post
Your AddMessage hook causes an infinite tail-call loop.
I don't think so, because it always works fine. This crash only happens when zoning in an INSTANCE. Also my ncChat addon uses the same hook system and that script doesn't crash.

EDIT: Thanks to the help of people that use ncUI I managed to narrow done the code which contains the problem:
lua Code:
  1. local x=({ChatFrameEditBox:GetRegions()})
  2. x[6]:SetAlpha(0)
  3. x[7]:SetAlpha(0)
  4. x[8]:SetAlpha(0)
  5. ChatFrameEditBox:ClearAllPoints()
  6. ChatFrameEditBox:SetPoint("TOPLEFT", ChatFrameEditBoxBackground)
  7. ChatFrameEditBox:SetPoint("BOTTOMRIGHT", ChatFrameEditBoxBackground)
  8.  
  9. local function enter()
  10.     for i=1,NUM_CHAT_WINDOWS do
  11.         local f = _G["ChatFrame"..i]
  12.         hideframe(_G["ChatFrame"..i.."UpButton"])
  13.         hideframe(_G["ChatFrame"..i.."DownButton"])
  14.         hideframe(_G["ChatFrame"..i.."BottomButton"])
  15.         f:SetFading(false)
  16.         f:EnableMouseWheel(true)
  17.             _G["ChatFrame"..i]:SetUserPlaced(true)
  18.         f:SetScript("OnMouseWheel", function(frame, delta)
  19.             if delta > 0 and IsShiftKeyDown() then
  20.                 frame:ScrollToTop()
  21.             elseif delta > 0 then
  22.                 frame:ScrollUp()
  23.             elseif delta < 0 and IsShiftKeyDown() then
  24.                 frame:ScrollToBottom()
  25.             else
  26.                 frame:ScrollDown()
  27.             end
  28.         end)
  29.         hooks[f] = f.AddMessage
  30.         f.AddMessage = addmessage
  31.     end
  32.     ChatFrame3:SetJustifyH("RIGHT")
  33.     ChatFrame3:ClearAllPoints()
  34.     ChatFrame3:SetPoint("TOPRIGHT", CubeRightBG, "TOPLEFT", -8, 0)
  35.     ChatFrame3:SetPoint("BOTTOMLEFT", InfoRight, "TOPLEFT", 0, 10)
  36.     ChatFrame3:Show()
  37.     ChatFrame3Tab:Hide()
  38.     ChatFrame1:ClearAllPoints()
  39.     ChatFrame1:SetPoint("TOPLEFT", CubeLeftBG, "TOPRIGHT", 8, 0)
  40.     ChatFrame1:SetPoint("BOTTOMRIGHT", InfoLeft, "TOPRIGHT", 0, 10)
  41.     SetCVar("chatLocked", 1)
  42.     hideframe(ChatFrameMenuButton)
  43. end
  44. local f = CreateFrame("Frame")
  45. f:SetScript("OnEvent", enter)
  46. f:RegisterEvent("PLAYER_ENTERING_WORLD")
  47. for i = 1,7 do
  48.     for k,v in pairs(CHAT_FRAME_TEXTURES) do
  49.         _G["ChatFrame"..i..v]:Hide()
  50.         CHAT_FRAME_TEXTURES[k] = nil
  51.     end
  52. end
__________________
Three things are certain,
Death, taxes and site not found,
You, victim of one.

Last edited by nightcracker : 02-16-10 at 08:27 AM.
  Reply With Quote
02-16-10, 08:24 AM   #6
Pas
A Defias Bandit
Join Date: Sep 2006
Posts: 3
I just saw that your active in this forum and that's why I post my outputs of my "job" in here rather than in the ncUI-Comments.

When I delete the line 33 to 126 there is no more freezing.
  Reply With Quote
02-16-10, 08:27 AM   #7
nightcracker
A Molten Giant
 
nightcracker's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 716
Even further narrowed down:
lua Code:
  1. local function enter()
  2.     for i=1,NUM_CHAT_WINDOWS do
  3.         local f = _G["ChatFrame"..i]
  4.         hideframe(_G["ChatFrame"..i.."UpButton"])
  5.         hideframe(_G["ChatFrame"..i.."DownButton"])
  6.         hideframe(_G["ChatFrame"..i.."BottomButton"])
  7.         f:SetFading(false)
  8.         f:EnableMouseWheel(true)
  9.             _G["ChatFrame"..i]:SetUserPlaced(true)
  10.         f:SetScript("OnMouseWheel", function(frame, delta)
  11.             if delta > 0 and IsShiftKeyDown() then
  12.                 frame:ScrollToTop()
  13.             elseif delta > 0 then
  14.                 frame:ScrollUp()
  15.             elseif delta < 0 and IsShiftKeyDown() then
  16.                 frame:ScrollToBottom()
  17.             else
  18.                 frame:ScrollDown()
  19.             end
  20.         end)
  21.         hooks[f] = f.AddMessage
  22.         f.AddMessage = addmessage
  23.     end
  24.     ChatFrame3:SetJustifyH("RIGHT")
  25.     ChatFrame3:ClearAllPoints()
  26.     ChatFrame3:SetPoint("TOPRIGHT", CubeRightBG, "TOPLEFT", -8, 0)
  27.     ChatFrame3:SetPoint("BOTTOMLEFT", InfoRight, "TOPLEFT", 0, 10)
  28.     ChatFrame3:Show()
  29.     ChatFrame3Tab:Hide()
  30.     ChatFrame1:ClearAllPoints()
  31.     ChatFrame1:SetPoint("TOPLEFT", CubeLeftBG, "TOPRIGHT", 8, 0)
  32.     ChatFrame1:SetPoint("BOTTOMRIGHT", InfoLeft, "TOPRIGHT", 0, 10)
  33.     SetCVar("chatLocked", 1)
  34.     hideframe(ChatFrameMenuButton)
  35. end
__________________
Three things are certain,
Death, taxes and site not found,
You, victim of one.
  Reply With Quote
02-16-10, 08:32 AM   #8
sacrife
An Onyxian Warder
 
sacrife's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 384
Have you tried commenting out line 21 and/or 22?
__________________

  Reply With Quote
02-16-10, 01:47 PM   #9
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Do you really need that code to run on every "PLAYER_ENTERING_WORLD" event? Or only when you log in? (That event fires when zoning.)
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
02-16-10, 02:48 PM   #10
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
Foxlit is correct about the issue and Seerah is right about how it is happening. Running that code any time you zone is your issue. More specifically:
Code:
hooks[f] = f.AddMessage
f.AddMessage = addmessage
Now think about what happens in your addmessage function when that gets called the second time:
Code:
return hooks[frame](frame, text, red, green, blue, id)
hooks[frame] now references addmessage and now you have an endless loop.

Easy fix with some clean up:
Code:
local function OnMouseWheel(self, delta)
	if delta > 0 then
		if IsShiftKeyDown() then
			self:ScrollToTop()
		else
			self:ScrollUp()
		end
	elseif IsShiftKeyDown() then
		self:ScrollToBottom()
	else
		self:ScrollDown()
	end
end

local f = CreateFrame('Frame')
f:RegisterEvent('PLAYER_ENTERING_WORLD')
f:SetScript('OnEvent', function(self)
	self:UnregisterAllEvents()
	self:SetScript('OnEvent', nil)
	for i = 1, NUM_CHAT_WINDOWS do
		local name = 'ChatFrame' .. i
		hideframe(_G[name .. 'UpButton'])
		hideframe(_G[name .. 'DownButton'])
		hideframe(_G[name .. 'BottomButton'])
		local f = _G[name]
		f:SetFading(false)
		f:EnableMouseWheel(true)
		f:SetUserPlaced(true)
		f:SetScript('OnMouseWheel', OnMouseWheel)
		hooks[f] = f.AddMessage
		f.AddMessage = addmessage
	end
	ChatFrame3:SetJustifyH('RIGHT')
	ChatFrame3:ClearAllPoints()
	ChatFrame3:SetPoint('TOPRIGHT', CubeRightBG, 'TOPLEFT', -8, 0)
	ChatFrame3:SetPoint('BOTTOMLEFT', InfoRight, 'TOPLEFT', 0, 10)
	ChatFrame3:Show()
	ChatFrame3Tab:Hide()
	ChatFrame1:ClearAllPoints()
	ChatFrame1:SetPoint('TOPLEFT', CubeLeftBG, 'TOPRIGHT', 8, 0)
	ChatFrame1:SetPoint('BOTTOMRIGHT', InfoLeft, 'TOPRIGHT', 0, 10)
	SetCVar('chatLocked', 1)
	hideframe(ChatFrameMenuButton)
end)
  Reply With Quote
02-16-10, 11:52 PM   #11
nightcracker
A Molten Giant
 
nightcracker's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 716
Originally Posted by Vrul View Post
Foxlit is correct about the issue and Seerah is right about how it is happening. Running that code any time you zone is your issue. More specifically:
Code:
hooks[f] = f.AddMessage
f.AddMessage = addmessage
Now think about what happens in your addmessage function when that gets called the second time:
Code:
return hooks[frame](frame, text, red, green, blue, id)
hooks[frame] now references addmessage and now you have an endless loop.

Easy fix with some clean up:
Code:
local function OnMouseWheel(self, delta)
	if delta > 0 then
		if IsShiftKeyDown() then
			self:ScrollToTop()
		else
			self:ScrollUp()
		end
	elseif IsShiftKeyDown() then
		self:ScrollToBottom()
	else
		self:ScrollDown()
	end
end

local f = CreateFrame('Frame')
f:RegisterEvent('PLAYER_ENTERING_WORLD')
f:SetScript('OnEvent', function(self)
	self:UnregisterAllEvents()
	self:SetScript('OnEvent', nil)
	for i = 1, NUM_CHAT_WINDOWS do
		local name = 'ChatFrame' .. i
		hideframe(_G[name .. 'UpButton'])
		hideframe(_G[name .. 'DownButton'])
		hideframe(_G[name .. 'BottomButton'])
		local f = _G[name]
		f:SetFading(false)
		f:EnableMouseWheel(true)
		f:SetUserPlaced(true)
		f:SetScript('OnMouseWheel', OnMouseWheel)
		hooks[f] = f.AddMessage
		f.AddMessage = addmessage
	end
	ChatFrame3:SetJustifyH('RIGHT')
	ChatFrame3:ClearAllPoints()
	ChatFrame3:SetPoint('TOPRIGHT', CubeRightBG, 'TOPLEFT', -8, 0)
	ChatFrame3:SetPoint('BOTTOMLEFT', InfoRight, 'TOPLEFT', 0, 10)
	ChatFrame3:Show()
	ChatFrame3Tab:Hide()
	ChatFrame1:ClearAllPoints()
	ChatFrame1:SetPoint('TOPLEFT', CubeLeftBG, 'TOPRIGHT', 8, 0)
	ChatFrame1:SetPoint('BOTTOMRIGHT', InfoLeft, 'TOPRIGHT', 0, 10)
	SetCVar('chatLocked', 1)
	hideframe(ChatFrameMenuButton)
end)
Hmm, indeed, that's the problem. But why do so much effort while it is a simple change from "PLAYER_ENTERING_WORLD" to "PLAYER_LOGIN"? :P
__________________
Three things are certain,
Death, taxes and site not found,
You, victim of one.
  Reply With Quote
02-17-10, 12:25 AM   #12
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
Because fixing a symptom leaves the root problem - it's just good practice to tie up all loose ends.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Crash on LFD zoning


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off