Thread Tools Display Modes
06/16/16, 01:53 PM   #1
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,578
bug in mailinbox_keyboard

I got the following error when I opened the mailbox after deleting a mail at the same time that I got removed from a dungeon instance:
Code:
EsoUI/Ingame/Mail/Keyboard/MailInbox_Keyboard.lua:440: attempt to index a nil value
stack traceback:
	EsoUI/Ingame/Mail/Keyboard/MailInbox_Keyboard.lua:440: in function 'MailInbox:RefreshMailFrom'
	EsoUI/Ingame/Mail/Keyboard/MailInbox_Keyboard.lua:398: in function 'MailInbox:OnInboxUpdate'
	EsoUI/Ingame/Mail/Keyboard/MailInbox_Keyboard.lua:54: in function '(anonymous)'
GetMailData can return a nil value, but most instances where it is used do not protect against it. It's a minor bug that probably doesn't occur often, but it also doesn't require much to fix it.
  Reply With Quote
06/18/16, 01:01 PM   #2
Lodur
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 108
Yes, I see this a lot too with my MailLooter addon. This was not an issue in previous ESO releases for a while... It was an issue before way over a year or two ago now.... It just started again with the DarkBrotherhood release.

I can reproduce it pretty easy with MailLooter. Just have only hireling mail in your inbox. Go to MailLooter and loot all hireling mail. Go back to the Inbox and Lua error...

Code:
EsoUI/Ingame/Mail/MailInbox_Shared.lua:51: attempt to index a nil value
stack traceback:
	EsoUI/Ingame/Mail/MailInbox_Shared.lua:51: in function 'ZO_MailInboxShared_PopulateMailData'
	EsoUI/Ingame/Mail/Keyboard/MailInbox_Keyboard.lua:425: in function 'MailInbox:OnMailReadable'
	EsoUI/Ingame/Mail/Keyboard/MailInbox_Keyboard.lua:49: in function 'callback'
	EsoUI/Libraries/Utility/ZO_CallbackObject.lua:111: in function 'ZO_CallbackObject:FireCallbacks'
	EsoUI/Libraries/ZO_Scene/ZO_Scene.lua:248: in function 'ZO_Scene:SetState'
	EsoUI/Libraries/ZO_Scene/ZO_Scene.lua:363: in function 'ZO_Scene:DetermineIfTransitionIsComplete'
	EsoUI/Libraries/ZO_Scene/ZO_Scene.lua:306: in function 'ZO_Scene:OnSceneFragmentStateChange'
	EsoUI/Libraries/ZO_Scene/ZO_SceneFragment.lua:108: in function 'ZO_SceneFragment:SetState'
	EsoUI/Libraries/ZO_Scene/ZO_SceneFragment.lua:114: in function 'ZO_SceneFragment:OnShown'
	EsoUI/Libraries/ZO_Scene/ZO_SceneFragmentTemplates.lua:57: in function '(anonymous)'
Deleting the last mail in the inbox from out code outside the inbox is the sure way to get this. But it happens other times as well. I think when the last select mail in the InBox is delete out from under the inbox.
  Reply With Quote
06/18/16, 01:43 PM   #3
Lodur
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 108
The problem may be that in:

https://github.com/esoui/esoui/blob/...x_keyboard.lua
Code:
function MailInbox:OnMailRemoved(mailId)
    self.reportedMailIds[zo_getSafeId64Key(mailId)] = nil
    self:RefreshData()
end
Needs to be:

Code:
function MailInbox:OnMailRemoved(mailId)
    if mailId == self.dirtyMail then
        self.dirtyMail = nil
    end

    self.reportedMailIds[zo_getSafeId64Key(mailId)] = nil
    self:RefreshData()
end

The crash in my post above is from MailInbox trying to load the mail info from a mailId (self.dirtyMail) for a mail that is now deleted.
  Reply With Quote
06/18/16, 02:15 PM   #4
Lodur
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 108
Actually make that:

Code:
function MailInbox:OnMailRemoved(mailId)
    if self.control:IsHidden() then
        if AreId64sEqual(mailId, self.dirtyMail) then
            self.dirtyMail = nil
        end

        if AreId64sEqual(mailId, self.mailId) then
            self.mailId = nil
        end
    end

    self.reportedMailIds[zo_getSafeId64Key(mailId)] = nil
    self:RefreshData()
end

Last edited by Lodur : 06/18/16 at 11:15 PM. Reason: Merlight's reminder about AreId64sEqual
  Reply With Quote
06/18/16, 02:33 PM   #5
Lodur
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 108
The MailLooter addon in version 1.1.1 is patching the above code into the MailInbox. If it causes anyone a problem please let me know.
  Reply With Quote
06/18/16, 03:36 PM   #6
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
You should be using AreId64sEqual to compare mailId
  Reply With Quote
06/18/16, 10:07 PM   #7
Lodur
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 108
Originally Posted by merlight View Post
You should be using AreId64sEqual to compare mailId
Thanks. Should have remembered that since the rest of my Addon does that....
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » bug in mailinbox_keyboard


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