changeset 39:8f7ec6ccf5e3

Comment/debug changes to help in tracking down cache bug. Do not run OnAccept when pressing Enter in an empty editbox.
author Farmbuyer of US-Kilrogg <farmbuyer@gmail.com>
date Thu, 29 Dec 2011 23:15:51 +0000
parents bb41be8f13b2
children dc3a66688e50
files LibFarmbuyer.lua core.lua gui.lua print_log.lua
diffstat 4 files changed, 23 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/LibFarmbuyer.lua	Fri Dec 23 01:08:02 2011 +0000
+++ b/LibFarmbuyer.lua	Thu Dec 29 23:15:51 2011 +0000
@@ -25,7 +25,7 @@
   Fills out "typical" settings inside T, especially if T contains any kind
   of editbox:
    + cannot accept an empty editbox
-   + pressing Enter runs OnAccept
+   + pressing Enter runs OnAccept (also will not accept empty editbox)
    + editbox grabs keyboard focus
    + OnAccept runs with editbox's text in dialog.usertext
   Returns T.
@@ -50,7 +50,7 @@
   Ditto for table recycling.
 ]]
 
-local MAJOR, MINOR = "LibFarmbuyer", 12
+local MAJOR, MINOR = "LibFarmbuyer", 13
 assert(LibStub,MAJOR.." requires LibStub")
 local lib = LibStub:NewLibrary(MAJOR, MINOR)
 if not lib then return end
@@ -144,9 +144,10 @@
 	end
 end
 local function EditBoxOnEnterPressed_accept (editbox)
-    local dialog = editbox:GetParent()
-    StaticPopupDialogs[dialog.which].OnAccept (dialog, dialog.data, dialog.data2)
-    dialog:Hide()
+	if editbox:GetText() == "" then return end
+	local dialog = editbox:GetParent()
+	StaticPopupDialogs[dialog.which].OnAccept (dialog, dialog.data, dialog.data2)
+	dialog:Hide()
 end
 local function OnShow_witheditbox (dialog, data)
 	local info = StaticPopupDialogs[dialog.which]
--- a/core.lua	Fri Dec 23 01:08:02 2011 +0000
+++ b/core.lua	Thu Dec 29 23:15:51 2011 +0000
@@ -697,7 +697,7 @@
 	local function prefer_local_loots (cache)
 		-- The function name is a bit of a misnomer, as local entries overwrite
 		-- remote entries as the candidate table is populated.  This routine is
-		-- here to extract the results once the cache timers have expired.
+		-- here to extract the final results once the cache timers have expired.
 		--
 		-- Keep this sync'd with the local_override branch below.
 		for i,sig in ipairs(candidates) do
@@ -738,7 +738,7 @@
 		self.dprint('loot',">>_do_loot, R:", recipient, "I:", itemid, "C:", count, "frm:", from, "ex:", extratext, "q:", iquality)
 
 		itemid = tonumber(ilink:match("item:(%d+)") or 0)
-		-- This is only a loop to make jumping out of it easy, and still do cleanup below.
+		-- This is only a 'while' to make jumping out of it easy and still do cleanup below.
 		while local_override or ((iquality >= self.threshold) and not opts.itemfilter[itemid]) do
 			if (self.rebroadcast and (not from)) and not local_override then
 				self:broadcast('loot', recipient, itemid, count)
@@ -746,7 +746,7 @@
 			if (not self.enabled) and (not local_override) then break end
 			local signature = recipient .. iname .. (count or "")
 			if from and self.recent_loot:test(signature) then
-				self.dprint('cache', "loot <",signature,"> already in cache, skipping")
+				self.dprint('cache', "remote loot <",signature,"> already in cache, skipping")
 			else
 				-- There is some redundancy in all this, in the interests of ease-of-coding
 				i = {
@@ -766,7 +766,8 @@
 					is_heroic	= self:is_heroic_item(ilink),
 				}
 				if local_override then
-					-- adding things by hand, don't wait for network cache timeouts
+					-- player is adding loot by hand, don't wait for network cache timeouts
+					-- keep this sync'd with prefer_local_loots above
 					if i.extratext == 'shard'
 					   or i.extratext == 'gvault'
 					   or i.extratext == 'offspec'
@@ -780,12 +781,12 @@
 					then
 						self:_addHistoryEntry(looti)
 					end
-					i = looti  -- mostly for gui's manual entry
+					i = looti  -- return value mostly for gui's manual entry
 				else
 					self.recent_loot:add(signature)
 					candidates[signature] = i
 					tinsert (candidates, signature)
-					self.dprint('cache', "loot <",signature,"> added to cache, candidate", #candidates)
+					self.dprint('cache', "loot <",signature,"> added to cache as candidate", #candidates)
 				end
 			end
 			break
@@ -1280,7 +1281,7 @@
 			local not_from_local = duration == nil
 			local signature = bossname .. reason
 			if not_from_local and self.recent_boss:test(signature) then
-				self.dprint('cache', "boss <",signature,"> already in cache, skipping")
+				self.dprint('cache', "remote boss <",signature,"> already in cache, skipping")
 			else
 				self.recent_boss:add(signature)
 				g_boss_signpost = #g_loot + 1
--- a/gui.lua	Fri Dec 23 01:08:02 2011 +0000
+++ b/gui.lua	Thu Dec 29 23:15:51 2011 +0000
@@ -1499,7 +1499,9 @@
 			w:SetType("checkbox")
 			w:SetLabel(d)
 			if d == "notraid" then
-				w:SetDescription("Tick this before enabling to make the addon work outside of raid groups")
+				w:SetDescription[[Tick this before enabling to make the addon work outside of raid groups]]
+			elseif d == "alsolog" then
+				w:SetDescription[[Also log all debug messages to disk. See print_log.lua in the addon folder for later viewing.]]
 			else
 				w:SetDisabled(not addon.DEBUG_PRINT)
 			end
@@ -2221,6 +2223,7 @@
 		end,]]
 	}
 	t.EditBoxOnEnterPressed = function(editbox)
+		if editbox:GetText() == "" then return end
 		local dialog = editbox:GetParent()
 		if not eoi_st_insert_OnAccept (dialog, dialog.data) then
 			dialog:Hide()  -- replicate OnAccept click behavior
--- a/print_log.lua	Fri Dec 23 01:08:02 2011 +0000
+++ b/print_log.lua	Thu Dec 29 23:15:51 2011 +0000
@@ -1,5 +1,10 @@
 #!/usr/bin/env lua
 
+--[[
+This is meant to be run from a command-line interpreter.  It's what I
+use in practice, but is shipping primarily an example.
+]]
+
 if not arg[1] or arg[1] == "" then
 	print"Usage:  lua print_log.lua /path/to/OuroLoot_savedvars.lua"
 	print"Don't forget to delete log table after viewing!"