Well it 's not "one" frame but many frames (f. e. if multiple plugins are using it) that get stored in:
Code:
CETA.chatTabs[x].control
CETA is my Subclass Instance defined as a Global like this:
Code:
CETA = ZO_Object:Subclass()
Everything is working as intended after load. Also when reloading the UI the Memory is fresh and clean and no Errors popup.
But when I'm porting to a Wayshrine (and only then!) it seems like my CETA object and every child (e. g. CETA.chatTabs) of it isn't cleaned / reset properly - it still persists in the Memory with the former state (and won't get reset even when I'm forcefully calling the garbage collector). That is why I will get an Error that a formerly created TopLevelWindow Control is already existing (e. g. Can't create Control. Control MY_DEBUG_CONSOLE is already existing).
That is due to client still triggering all loading Events like it 's a "clean" start in my case. The same goes for the TopLevelWindow Control (CETA.chatTabs[x].control) - it 's still existing in the Memory including all of it 's children (e.g. Buttons, Background and so on).
The Events I'm speaking about are Setup and Registered like this:
Code:
function CETA:OnAddOnLoaded(event, name) ... end
function CETA:OnPlayerActivated() CALLBACK_MANAGER:FireCallbacks("CETA_ADD_TABS", self) end
em:RegisterForEvent(self.addonName.."_OnAddOnLoaded", EVENT_ADD_ON_LOADED, function(...) self:OnAddOnLoaded(...) end)
em:RegisterForEvent(self.addonName.."_OnPlayerActivated", EVENT_PLAYER_ACTIVATED, function(...) self:OnPlayerActivated(...) end)
As far as I found out (I'm pretty new to Lua) it seems like that the Garbage Collector failed to clean up the Memory correctly. That might be due to the way the native API-Functions and their metatable are setup or because my code itself is setup in a way that the Garbage Collector can't grab it by itself. Sounds logical, due to CETA being a global and not a local variable. Maybe ZOS is usually calling an selfmade Garbage-Collector for Plugins at load which won't get called when porting to minimize the loading time or they just simply forgot to call it? Hm.
Either way, by traversing and niling with my above functions it I'm able to get it garbage collected successfully before re-initializing it properly again. I could've choosen to work with the old copy from the Memory but that might lead to more problems in the future due to wrong memory addresses and stuff which seems worse to me then to marking it up for cleanup for myself and reinitializing it once after porting.
Is that a bad practice or a wrong conclusion (as said I'm a pretty new to Lua, so I'm a bit unsure) ?
Cheers!