Skip to content

Commit

Permalink
Fixed an error that appears when trying to delete an instance that is…
Browse files Browse the repository at this point in the history
… already deleted. (#109)

* Prevent deleting already removed instances.

* Prehashed empty hash.

* Use go.exists instead of pcall, when detecting non existing instances.
  • Loading branch information
paweljarosz committed Mar 4, 2024
1 parent b78b896 commit 6ba3064
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions monarch/monarch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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


Expand Down

0 comments on commit 6ba3064

Please sign in to comment.