Bug fix an issue where a player leaves and rejoins during combat things get broken, tending to generate:

Mere [08-03-13 - 14:24]
Bug fix an issue where a player leaves and rejoins during combat things get broken, tending to generate:
attempt to index field ''PlayerEvents'' (a nil value)

This was because old panel was listed as associated with the unitid, but the player info object it was referencing was the old one, which didn't have player events any more.

Fix it so that when a playerinfo object is deleted also remove the table tracking panels for that unitid, as new ones will be setup when the player is joined to panels/layouts.

This makes sure that updates for that unit don't get processed on the old panel.

One side effect, if a player leaves and rejoins we leave them in a left group state, but that should be relatively rare.

I may look at ways to improve it longer term, possibly not storing the playerinfo object in the healing panel (or properly linking it to the newly created one)

Bump version for this fix.
Filename
CommandLine.lua
HealingPanel.lua
RaidManagement.lua
RiftAddon.toc
diff --git a/CommandLine.lua b/CommandLine.lua
index ddc744a..a4e646e 100644
--- a/CommandLine.lua
+++ b/CommandLine.lua
@@ -327,7 +327,7 @@ function MereHealingFrames.Commands.Debug(params)
 end

 function MereHealingFrames.PanelWalk()
-		for unitId, panels in ipairs(MereHealingFrames.UnitIdPanels) do
+		for unitId, panels in pairs(MereHealingFrames.UnitIdPanels) do
 			print("Panels for unit ID: " .. unitId)
 			for key, panel in pairs(panels) do
 				print("Panel: " .. panel.unitId)
diff --git a/HealingPanel.lua b/HealingPanel.lua
index 9b282c0..ab38774 100644
--- a/HealingPanel.lua
+++ b/HealingPanel.lua
@@ -161,7 +161,7 @@ function MereHealingFrames.HealingPanel:SetPlayerInfo(playerInfo)
 	self.unitId = playerInfo.unitId

 	local panels = MereHealingFrames.UnitIdPanels[self.unitId] or {}
-	table.insert(panels, self)
+	panels[self] = self
 	MereHealingFrames.UnitIdPanels[self.unitId] = panels

 	self:SetupPlayerValues()
@@ -195,22 +195,10 @@ function MereHealingFrames.HealingPanel:RemoveUnitId()
 end

 function MereHealingFrames.HealingPanel:UnHookPanel()
-	local index = nil
-
     local UnitIdPanels = MereHealingFrames.UnitIdPanels[self.unitId]
-
-	for i, panel in ipairs(UnitIdPanels) do
-		if (panel == self) then
-			index = i
-			break
-		end
-	end
-
-	if (index == nil) then
-		error("Unable to unhook panel, how did we loose it?, unitId: " .. self.unitId)
-	end
-
-	table.remove(UnitIdPanels, index)
+    if UnitIdPanels then
+        UnitIdPanels[self] = nil
+    end
 end

 function MereHealingFrames.HealingPanel:SetupPlayerValues()
diff --git a/RaidManagement.lua b/RaidManagement.lua
index fb7ed27..b915fdb 100644
--- a/RaidManagement.lua
+++ b/RaidManagement.lua
@@ -70,8 +70,6 @@ local function calculateGrouping(spec)
 	return group
 end

-
-
 function playerInfo:new(settings, unitId, spec)
 	if (unitId == nil) or (spec == nil) then
 		error("must provide basic player info")
@@ -139,12 +137,13 @@ function playerInfo:delete()
 	MereHealingFrames.RaidManagement.Specifiers[self.specifier] = nil
     MereHealingFrames.PlayerEventManager.OldEvents(self.PlayerEvents)
     self.PlayerEvents = nil
+    MereHealingFrames.UnitIdPanels[self.unitId] = nil
 end

 local function PanelUpdate(unitId, targetFunction, value)
     if not targetFunction then return end
 	local panels = MereHealingFrames.UnitIdPanels[unitId] or {}
-	for i, panel in ipairs(panels) do
+	for i, panel in pairs(panels) do
 		targetFunction(panel, value)
 	end
 end
diff --git a/RiftAddon.toc b/RiftAddon.toc
index 8777699..10f33df 100644
--- a/RiftAddon.toc
+++ b/RiftAddon.toc
@@ -7,7 +7,7 @@ Name = "Mere Healing Frames"
 NameShort = "MHF"
 Description = "A set of healing frames"
 Author = "Mere"
-Version = "0.4.33"
+Version = "0.4.34"
 Email = "rift@dokein.co.uk"
 Environment = "2.3"