SavedVariables Problem...Any Ideas?
Anyone have any ideas on this.
Whenever the function (below) runs and adds the scriptName & script to the scripts table...and then I try to reload the UI (or just wait long enough) the game crashes & the saved variable file is over 1 gig. That is the only line of code that adds anything to the saved variables file. Code Paste here, Line 392 is the problem: http://pastebin.com/sjnG4v9d Or if you want/need to see the whole addon you can find it here: Drop Box Zip File CLICK4INFO.sv -- Is my saved variables CLICK4INFO.sv.scripts -- Is just an empty table to start out. Lua Code:
|
I think the problem is the DoesScriptNameExist function.
CLICK4INFO.sv.scripts is a indexed table (using table.insert) The function should be like this: Lua Code:
CU |
Quote:
Lua Code:
|
Quote:
But, that does not solve the problem. |
Quote:
Lua Code:
But if I do it like that then every time I try to populate the scroll list with that information I would have to copy it into another table & reorganize it like this any way: Lua Code:
Because in When you call: Lua Code:
Lua Code:
Lua Code:
Although I could do that..it just seemed like a waste and slower. My choices are do a little extra function call with special code to see if a scriptName already exists, which only runs when you add a new script. Or Repack all of the information into a new table every time the data is displayed. The only thing that stops the error (without changing it to the old way that Garkin suggested) is commenting out this line: Lua Code:
|
EDIT: I had tried to open the saved variable file before to see what was in it, why it was getting so large but notepad++ always crashed. I got lucky this time & was able to open it & see what was getting saved in the scripts table.
Which now knowing what was in there I was able to find the problem. This function calls ZO_ScrollList_CreateDataEntry Lua Code:
Which causes some recursion here copying data into itself, data.dataEntry.data = data Which I guess is ok for items in the game ? not sure why or what the purpose of that is ? but since the data object I was passing in was a table inside the saved variable file it was doing that recursion in the saved variable file saving data inside its self infinitely. Lua Code:
Saved Variable file scripts table: |
I guess I also sometimes see this inside ZGOO when I inspect controls.
They seem to have an data entry which got another data entry with a third data entry and so on. I was always wondering why was shown this way and thought it's only a "visual" problem with ZGOO, where parents and childs (where parent and child are the same somehow) are shown in the same control again. |
Lua tables are essentially references, so it's not that uncommon/difficult to have some nested loops.
For example, this is really all you need for setting it up: Lua Code:
I'm not sure that you can throw a recursive table structure into SavedVars normally, so probably create it elsewhere and do a deep copy that removes those references. Here's a gist someone put up on different deep copy methods: https://gist.github.com/tylerneylon/...21109155b2d244 |
Quote:
Thats what I did to solve it, I just did a deep copy and used that to add the data rows to the scroll list. BTW, theres already a built in function for it: Lua Code:
Thanks everyone for the ideas ! |
You could also get around that by giving CreateDataEntry a wrapper table instead of copying the data:
Lua Code:
Or use a metatable: Lua Code:
|
All times are GMT -6. The time now is 02:26 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI