Reusing frames the proper way
Hi
I have a wierd bug with my addon and I have really no idea how to fix it. First how it works: Once you get to combat addon scans your action bars and remebers them by spell that are on specific button. If external module (ex. TDDps_Warlock) calls for a glowing a button, main addon (TDDps) creates overlay on specific button spell (ex Immolate) and shows a glow on it. Everything works EXCEPT changing specializations. I am listening on 'PLAYER_TALENT_UPDATE' event and calling TDDps_DisableAddon();. Enable/disable/init sequence is like this: Lua Code:
Event system seems to be working fine. I think I have a problem with reusing frames becasue when i change specialization and enter combat 'PLAYER_REGEN_DISABLED' some wierd things are going. Spells are either not overlaying or some random spells are. Here is my reusing frames system: Lua Code:
Any idea what I might be doing wrong here? |
Rather than tremove and tinsert (which don't return anything) add the frame to your table by name
Code:
TDButton_FramePool = {}; |
Quote:
|
I Changed Destroy() to just hide them.
WoWProgramming doesn't mention tremove returning a value so I always assumed it didn't. I need to start checking more sources :o |
Turned out i'm blind and forgot to remove layers from parent button:
Lua Code:
that line did the job: frame:GetParent().tdOverlays = nil; Because at the begining of the showing overlay i had: Lua Code:
|
Is there a reason why you can't combine both loops to make it easier on the CPU?
Lua Code:
|
Is this really worth it? We are only talking about some memory usage here, that you willing to trade for cpu usage. Mostly this method will only be good on things like very big addon options gui, and there is a pretty big chance that options module is LOD.
|
Honestly, it's a judgement call on how many UI objects you're comfortable creating and the ratio of used and unused objects. There will always be overhead when recycling resources. It's a balance between how frequent you're going to be reallocating such resources and how much would otherwise go to waste. This code can still be optimized to be lighter on both memory and CPU.
|
Quote:
|
Again, it's a judgement call. There are plenty of pros and cons on both sides.
|
All times are GMT -6. The time now is 08:08 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI