5 - Dual spec profile and current getting swapped during initialization

What steps will reproduce the problem?
1. While in an addons OnInitialize, create two new profiles, lets call them A and B
2. Set profile A to be current profile
3. SetDualSpecEnabled to true and SetDualSpecProfile to profile B
4. output state to chat frame for sanity check: print("current profile is:", self.db:GetCurrentProfile() "  alt profile is:", self.db:GetDualSpecProfile())
5. log in, go into options and check what current and alternate profiles are set to

What is the expected output? What do you see instead?
The expected result is for profile A to be the current profile and for profile B to be set as the alternative spec.  The chat frame output confirms that at the time the print statement ran, that was the case.  When you look at the profile options ui (or trigger the print statement again) you see that the two have swapped with the current profile listed as being B and the alternate profile set as A.

Please provide any additional information below.
The problem only happens when SetDualSpecProfile is called. Of course, if don't then both are set to profile A which isn't much better.

If I wait for the game to load and then from the chatline trigger the SetDualSpecProfile call then the when I load up the profile options UI things are correct.

I've taken over maintenance of addon with a very poor implementation of profile support including a half-baked attempt at doing their own version of supporting dual specs. I want to roll out an update that fixes all of this and will migrate existing users settings seamlessly over into the new layout.  So, during addon initialization I'm grabbing all of the settings and constructing two new profiles and changing the current profile to be the new one for the active spec. Ideally at the same time I want to set the second spec up with libdualspec.

Doing this right means that users need not even know we made any changes, while opening up the full power of profiles for those that want to use it or were frustrated by the bugs in the old implementation.

This seems to me a bug in libdualspec with regards to it thinking it needs to do a swap. A fix or information about how to work around the problem (if there's a known timing issue) would be appreciated.

User When Change
nebula169 Jul 18, 2016 at 17:30 UTC Changed status from New to Invalid
stencil Jan 12, 2012 at 21:26 UTC Create

You must login to post a comment. Don't have an account? Register to get one!

  • Avatar of stencil stencil Aug 09, 2012 at 00:33 UTC - 0 likes

    @Adirelle: Go

    Oh gosh, sorry, didn't realize I had never followed up with on you this. I guess its been a long time since I looked at the list of open tickets submitted by me ...

    The steps described in the report were producing the bug every time. Since I was working on profile migration at the time, I had a backup copy of my addons saved settings file. Between first seeing the problem and concluding the investigation were multiple iterations of exiting wow, replacing the addon settings file with a copy of the saved original version, restarting wow, logging in and seeing the problem.

    Its my recollection that the bug would also reproduce regardless of which spec your character was in during login. That's why I simplified and genericized the repro steps to just call the specs A and B (with A always being set as the current profile, regardless of what spec you were in) when my original code was creating profiles named Primary and Secondary. So, when I'd run the scenario where my toon's main spec was the currently active spec I'd end up with the Secondary profile being current; when I'd run it with the toon's off spec active I'd end up with the Primary profile being current. Then I changed the code to the simpler A/B profile test case and verified that regardless of the spec you logged in with if you call SetDualSpecProfile during OnInitialize then you get the inversion. At least that's how I remember it.

    As far as when talent info is available, I'm don't particularly remember whether calling GetActiveTalentGroup during OnInitialize ever returned an incorrect value. Even if it did, the A/B test case form that reproduces the problem does not call GetActiveTalentGroup or care which spec is active. It simply tries to make A the profile for the current spec and B the profile for the other spec but the values end up getting swapped. If LibDualSpec was failing from bad GetActiveTalentGroup return values, the bug would seem to be that LibDualSpec was even calling it.

    If I were to speculate about what could be happening in LibDualSpec ... Seems like maybe as a result of calling SetDualSpecProfile in my OnInitialize, some internal flag of yours is set (like a cache invalidation) or perhaps an event or function hook is created at an earlier time than is normally expected. As a result, some event that WoW has probably always fired off during login, and which is normally ignored or not even seen by LibDualSpec, is now being processed and viewed as the sign that the user has swapped specs.

    In the end, I just worked around the problem by moving my calls of SetDualSpecEnabled and SetDualSpecProfile down to OnEnable.

  • Avatar of Adirelle Adirelle Jan 13, 2012 at 09:18 UTC - 0 likes

    This is clearly a timing issue: LibDualSpec (LDS) has to wait until talent information are available, which generally happens after OnInitialize and OnEnable. However, I am not sure why it considers it should swap the current spec and the new one. Does this reproduce *every* time ?



Last updated
Jul 18, 2016
Jan 12, 2012
Invalid - This was not a valid report.
Defect - A shortcoming, fault, or imperfection
Medium - Normal priority.

Reported by

Possible assignees