Quantcast Issue with LibDBIcon and not seeing Ace3 preference database - WoWInterface
Thread Tools Display Modes
10-07-18, 07:48 PM   #1
Buran
A Kobold Labourer
Join Date: Jan 2015
Posts: 1
Question Issue with LibDBIcon and not seeing Ace3 preference database

Hi everyone!

Error I'm fighting:

Code:
Interface\AddOns\<addon>\minimap.lua:43: attempt to index field 'db' (a nil value)
I'm declaring LDB support -- which was very easy to add and works well with both text and icon based display -- like this:

Code:
LDB           = LibStub:GetLibrary("LibDataBroker-1.1")
DBIcon        = LibStub("LibDBIcon-1.0")
and


Code:
Me.LDBButton = LDB:NewDataObject(LDBLongLabel, {
	type          = "launcher",
	icon          = "Interface\\Icons\\inv_misc_dice_01",
	label         = LDBShortLabel,
	text          = LDBShortLabel,
	tocname       = MyTOCName,
	OnClick       = function(clickedframe, button) Me.HandleLDBButtonClick() end,
	OnTooltipShow = function(tooltip)
		Me.UpdateFDRLauncherTooltip()
		tooltip:SetText(LDBLongLabel)
		tooltip:AddLine(Me.UpdateFDRLauncherTooltip())
	end,
})
where LDBLongLabel is a string containing the addon's 'pretty' name (with spaces). LDBShortLabel is another string containing an abbreviated form of the addon's name, and is what shows up in ElvUI's datatext panels in my minimap. Similarly, MyTOCName is a string containing the addon's name with no spaces (the name of its folder, etc).

Guild mates who have installed the addon in icon-based LDB packages see the icon just fine.

Then, I try to offer a minimap button as well:

Code:
DBIcon:Register(LDBLongLabel, Me.LDBButton, Me.db.global.MiniMapButton)
This fails with the error at the top of this post -- that's the troublesome line the error stack is calling out. The AceDB database looks like this:

Code:
Me.defaults = {
	profile = {
		(a bunch of defaults for UI, etc).
		},
	};
	global = {
		MiniMapButton = {};
	};
}
as a working addon using this code declared it that way; I've also tried pre-declaring the key
Code:
hide=true
with no difference. It's hung up on not being able to see the database. As far as I can tell, the item declarations match. I'm not sure what I'm missing, but it's probably something similar. Can someone familiar with LibDBIcon be of help?

For now, everything works fine with the DBIcon declaration taken out, so I've done that.
  Reply With Quote
10-07-18, 09:09 PM   #2
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 726
Probably your db is declared later in the loading process.
Make sure to delay the creation of the icon until your db is created.
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Issue with LibDBIcon and not seeing Ace3 preference database

Thread Tools
Display Modes

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