common-utils.lua: use different timeout callbacks for different states
This allows saving different states at the same time.
This commit is contained in:
@@ -102,19 +102,23 @@ function cutils.arrayContains (a, value)
|
||||
return false
|
||||
end
|
||||
|
||||
state_save_sources = {}
|
||||
|
||||
function cutils.storeAfterTimeout (state, state_table)
|
||||
if timeout_source then
|
||||
timeout_source:destroy ()
|
||||
local state_name = state["name"]
|
||||
if state_save_sources [state_name] ~= nil then
|
||||
state_save_sources [state_name]:destroy ()
|
||||
state_save_sources [state_name] = nil
|
||||
end
|
||||
local timeout_source = Core.timeout_add (1000, function ()
|
||||
state_save_sources [state_name] = Core.timeout_add (1000, function ()
|
||||
local saved, err = state:save (state_table)
|
||||
if not saved then
|
||||
Log.warning (err)
|
||||
end
|
||||
timeout_source = nil
|
||||
return false
|
||||
end)
|
||||
end
|
||||
|
||||
cutils.default_metadata_om:activate ()
|
||||
|
||||
return cutils
|
||||
return cutils
|
||||
|
Reference in New Issue
Block a user