3
0
mirror of https://github.com/britzl/monarch.git synced 2025-06-27 02:17:53 +02:00

Fixed an error that appears when trying to delete an instance that is already deleted. (#109)

* Prevent deleting already removed instances.

* Prehashed empty hash.

* Use go.exists instead of pcall, when detecting non existing instances.
This commit is contained in:
Pawel 2024-03-04 16:06:56 +01:00 committed by GitHub
parent b78b896ada
commit 6ba3064749
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -430,7 +430,9 @@ local function unload(screen, force)
elseif screen.factory then
log("unload() factory", screen.id)
for id, instance in pairs(screen.factory_ids) do
go.delete(instance)
if go.exists(instance) then
go.delete(instance)
end
end
screen.factory_ids = nil
if screen.auto_preload and not force then
@ -1374,8 +1376,10 @@ function M.on_post(id, fn_or_url)
end
end
local empty_hash = hash("")
local function url_to_key(url)
return (url.socket or hash("")) .. (url.path or hash("")) .. (url.fragment or hash(""))
return (url.socket or empty_hash) .. (url.path or empty_hash) .. (url.fragment or empty_hash)
end