Quantcast

Fix "script ran too long" by unhooking shit while in combat. Lesser of 2 evils.

Darthpred [09-13-16 - 20:03]
Fix "script ran too long" by unhooking shit while in combat. Lesser of 2 evils.
Filename
ElvUI_SLE/modules/chat/chat.lua
ElvUI_SLE/modules/chat/links.lua
diff --git a/ElvUI_SLE/modules/chat/chat.lua b/ElvUI_SLE/modules/chat/chat.lua
index 4ebe4e2..36991c0 100644
--- a/ElvUI_SLE/modules/chat/chat.lua
+++ b/ElvUI_SLE/modules/chat/chat.lua
@@ -130,6 +130,12 @@ function C:GMIconUpdate()
 end

 function C:Combat(event)
+	--To get rid of "script ran too long" in links
+	if event == "PLAYER_REGEN_DISABLED" then
+		C:Unhook("SetItemRef")
+	elseif event == "PLAYER_REGEN_ENABLED" then
+		C:RawHook("SetItemRef", true)
+	end
 	if C.db.combathide == "NONE" or not C.db.combathide then return end
 	if event == "PLAYER_REGEN_DISABLED" then
 		if C.db.combathide == "BOTH" or C.db.combathide == "RIGHT" then
@@ -140,6 +146,7 @@ function C:Combat(event)
 			LeftChatPanel:Hide()
 			LeftChatToggleButton:Hide()
 		end
+
 	elseif event == "PLAYER_REGEN_ENABLED" then
 		if not RightChatPanel:IsShown() then
 			RightChatPanel:Show()
diff --git a/ElvUI_SLE/modules/chat/links.lua b/ElvUI_SLE/modules/chat/links.lua
index 7fdd779..6ce418d 100644
--- a/ElvUI_SLE/modules/chat/links.lua
+++ b/ElvUI_SLE/modules/chat/links.lua
@@ -164,32 +164,30 @@ function C:ParseChatEventInv(event, msg, sender, ...)
 end

 function C:SetItemRef(link, text, button, chatframe)
-	if not T.InCombatLockdown() then
-		local linktype, id = T.split(":", link)
-		if C.db.dpsSpam then
-			if linktype == "SLD" then
-				local meterID = T.tonumber(id)
-				-- put stuff in the ItemRefTooltip from FrameXML
-				ShowUIPanel(ItemRefTooltip);
-				if ( not ItemRefTooltip:IsShown() ) then
-					ItemRefTooltip:SetOwner(UIParent, "ANCHOR_PRESERVE");
-				end
-				ItemRefTooltip:ClearLines()
-				ItemRefTooltip:AddLine(C.Meters[meterID].title)
-				ItemRefTooltip:AddLine(T.format(L["Reported by %s"],C.Meters[meterID].src))
-				for _,message in T.ipairs(C.Meters[meterID].data) do ItemRefTooltip:AddLine(message,1,1,1) end
-				ItemRefTooltip:Show()
-				return nil
+	local linktype, id = T.split(":", link)
+	if C.db.dpsSpam then
+		if linktype == "SLD" then
+			local meterID = T.tonumber(id)
+			-- put stuff in the ItemRefTooltip from FrameXML
+			ShowUIPanel(ItemRefTooltip);
+			if ( not ItemRefTooltip:IsShown() ) then
+				ItemRefTooltip:SetOwner(UIParent, "ANCHOR_PRESERVE");
 			end
-		end
-		if IsAltKeyDown() and linktype == "player" and E.db.sle.chat.invite.altInv then
-			InviteUnit(id)
-			return nil
-		elseif linktype == "invite" then
-			InviteUnit(id)
+			ItemRefTooltip:ClearLines()
+			ItemRefTooltip:AddLine(C.Meters[meterID].title)
+			ItemRefTooltip:AddLine(T.format(L["Reported by %s"],C.Meters[meterID].src))
+			for _,message in T.ipairs(C.Meters[meterID].data) do ItemRefTooltip:AddLine(message,1,1,1) end
+			ItemRefTooltip:Show()
 			return nil
 		end
 	end
+	if IsAltKeyDown() and linktype == "player" and E.db.sle.chat.invite.altInv then
+		InviteUnit(id)
+		return nil
+	elseif linktype == "invite" then
+		InviteUnit(id)
+		return nil
+	end
 	return self.hooks.SetItemRef(link, text, button)
 end

@@ -225,7 +223,7 @@ end
 function C:InitLinks()
 	C:SpamFilter()
 	C:CreateInvKeys()
-	C:RawHook(nil, "SetItemRef", true)
+	C:RawHook("SetItemRef", true)
 	-- Borrowed from Deadly Boss Mods
 	do
 		local old = ItemRefTooltip.SetHyperlink -- we have to hook this function since the default ChatFrame code assumes that all links except for player and channel links are valid arguments for this function