Ace3: Profile reset does not refresh config dialog? - WoWInterface
Thread Tools Display Modes
03-06-20, 07:00 AM   #1
A Black Drake
AddOn Compiler - Click to view compilations
Join Date: Jan 2010
Posts: 86
Ace3: Profile reset does not refresh config dialog?


I wonder how I can refresh the ace config dialog after I perform a profile reset (using Ace3).

Lua Code:
  1. function MyUI:SetupOptions()
  2.     MyUI.options = {
  3.         type = "group",
  4.         name = "My UI",
  5.         args = {};
  6.     };
  7.     MyUI.options.args.profile = DB_OPTIONS:GetOptionsTable(MyUI.db);
  8.     MyUI.options.args.profile.order = -10;
  9.     MyUI.options.args.profile.args.reset.confirm = true;
  11.     CONFIG:RegisterOptionsTable(MyUI.ADDON_NAME, MyUI.options);
  12.     CONFIG:RegisterOptionsTable(MyUI.ADDON_NAME .. "_Profile", MyUI.options.args.profile);
  14.     CONFIG_DIALOG:AddToBlizOptions(MyUI.ADDON_NAME, "My UI");
  15.     CONFIG_DIALOG:SetDefaultSize(MyUI.ADDON_NAME, MyUI:DefaultConfigSize());
  16. end

Lua Code:
  1. function MyUI:OnInitialize()
  2.     self.db = DB:New("MyDB", defaults, true);
  3.     self.db.RegisterCallback(self, "OnProfileChanged", "RefreshConfig");
  4.     self.db.RegisterCallback(self, "OnProfileCopied", "RefreshConfig");
  5.     self.db.RegisterCallback(self, "OnProfileReset", "RefreshConfig");
  6. end
  8. function MyUI:RefreshConfig()
  9.     -- This calls every sub module to refresh it's state
  10.     self:OnUpdate();
  11. end

When I press the "Reset Profile" button all my settings are getting reset but the ace config dialog which is currently open and where I pressed the reset profile button in is not updating to the new state. I need to reload the UI to get the config dialog to show the new state. But that is not all, the options are also all broken. Those settings which got reset cant get configured by ace config dialog anymore until I reloaded the UI. Nothing happens when I use them without reloading the UI.

I tried using:

Lua Code:
  1. function MyUI:RefreshConfig()
  2.     -- This calls every sub module to refresh it's state
  3.     self:OnUpdate();
  6. end

But it has no effect. I would expect that the config dialog refreshes automatically after I reset the profile through ace3 internal functions. Is there any way I can refresh the config dialog without reloading the UI?

Last edited by Lybrial : 03-06-20 at 07:03 AM.
  Reply With Quote
03-06-20, 08:09 AM   #2
A Black Drake
AddOn Compiler - Click to view compilations
Join Date: Jan 2010
Posts: 86
Resetting the profile DOES reset the config dialog. The code above works perfectly.
The error in my case was caused by something different, hidden deep inside the code.
  Reply With Quote
03-06-20, 06:54 PM   #3
A Pyroguard Emberseer
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,111
There is no need to use NotifyChange unless you alter the settings via an external method like a LDB display or minimap button.

Other issues:
  • You don't specify the profile subtable within the defaults table.
  • There is no need to load all the Ace3 modules globally across your addon. AceDB and AceConfig can be local to OnInitialize.
  • Lua does not require ending lines of code with a semicolon. Lua totally ignores ; at the end of a line.

local MyAddOn = LibStub("AceAddon-3.0"):NewAddon("MyAddOn")

local db

local defaults = {
    profile = {
        cats = true,

function MyAddOn:Initialize()
    self.db = LibStub("AceDB-3.0"):New("MyAddOnDB", defaults, true)
    self.db.RegisterCallback(self, "OnProfileChanged", "RefreshConfig")
    self.db.RegisterCallback(self, "OnProfileCopied", "RefreshConfig")
    self.db.RegisterCallback(self, "OnProfileReset", "RefreshConfig")
    db = self.db

function MyAddOn:RefreshConfig()
    db = self.db
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Ace3: Profile reset does not refresh config dialog?

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