Yeah, it's the combination of loop + that Ultraschall function. The latter opens the file each time and runs through it to find the section number if you give. It does close the file afterward, but it looks like Lua isn't cleaning up quickly enough after itself.
I don't have time to test this right now, but try:
Code:
local function list_keys_in_ini_section (section, fn)
local sections = {}
local LOOKING = 1
local WORKING = 2
local DONE = 3
local status = LOOKING
for line in io.lines(fn) do
if status == LOOKING and line:match("%["..section.."%]") then
status = WORKING
else if status == WORKING then
if line:match(".+=.+") then
sections.insert(line)
else
status = DONE
end
end
return sections
end
function get_preset_list()
local found_presets = list_keys_in_ini_section("menubox_EXAMPLE", reaper_extstate_ini_path)
if #found_presets > 0 then
preset_list = found_presets
end
-- number_of_presets, _ = ultraschall.CountIniFileExternalState_key("menubox_EXAMPLE", reaper_extstate_ini_path)
-- if number_of_presets > 0 then
-- for k in pairs (preset_list) do
-- preset_list[k] = nil
-- end
-- for i = 1, number_of_presets do
-- local preset_name = ultraschall.EnumerateIniFileExternalState_key("menubox_EXAMPLE", i, reaper_extstate_ini_path)
-- table.insert(preset_list, preset_name)
-- end
-- return preset_list
-- end
end