mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
BookInfoManager: Actually close the document after extraction
DocumentRegistry just decreases a ref, it doesn't close anything. Plug the same Document leak in a few other places, and document this.
This commit is contained in:
@@ -126,7 +126,7 @@ function BookInfo:show(file, book_props)
|
||||
book_props = document:getProps()
|
||||
book_props.pages = pages
|
||||
end
|
||||
DocumentRegistry:closeDocument(file)
|
||||
document:close()
|
||||
end
|
||||
end
|
||||
|
||||
@@ -219,7 +219,7 @@ function BookInfo:show(file, book_props)
|
||||
fullscreen = true,
|
||||
}
|
||||
end
|
||||
DocumentRegistry:closeDocument(file)
|
||||
document:close()
|
||||
end
|
||||
if not widget then
|
||||
widget = InfoMessage:new{
|
||||
|
||||
@@ -91,6 +91,7 @@ function Document:unlock(password)
|
||||
end
|
||||
|
||||
-- this might be overridden by a document implementation
|
||||
-- (in which case, do make sure it calls this one, too, to avoid refcounting mismatches in DocumentRegistry!)
|
||||
function Document:close()
|
||||
local DocumentRegistry = require("document/documentregistry")
|
||||
if self.is_open then
|
||||
|
||||
@@ -191,6 +191,7 @@ function DocumentRegistry:mimeToExt(mimetype)
|
||||
return self.mimetype_ext[mimetype]
|
||||
end
|
||||
|
||||
--- Returns a new Document instance on success
|
||||
function DocumentRegistry:openDocument(file, provider)
|
||||
-- force a GC, so that any previous document used memory can be reused
|
||||
-- immediately by this new document without having to wait for the
|
||||
@@ -219,6 +220,8 @@ function DocumentRegistry:openDocument(file, provider)
|
||||
end
|
||||
end
|
||||
|
||||
--- Does *NOT* finalize a Document instance, call its :close() instead if that's what you're looking for!
|
||||
--- (i.e., nothing but Document:close should call this!)
|
||||
function DocumentRegistry:closeDocument(file)
|
||||
if self.registry[file] then
|
||||
self.registry[file].refs = self.registry[file].refs - 1
|
||||
|
||||
@@ -544,7 +544,7 @@ function BookInfoManager:extractBookInfo(filepath, cover_specs)
|
||||
end
|
||||
end
|
||||
end
|
||||
DocumentRegistry:closeDocument(filepath)
|
||||
document:close()
|
||||
else
|
||||
loaded = false
|
||||
end
|
||||
|
||||
@@ -335,7 +335,7 @@ function CoverMenu:updateItems(select_number)
|
||||
})
|
||||
end
|
||||
UIManager:close(self.file_dialog)
|
||||
DocumentRegistry:closeDocument(file)
|
||||
document:close()
|
||||
end
|
||||
end,
|
||||
},
|
||||
@@ -468,7 +468,7 @@ function CoverMenu:onHistoryMenuHold(item)
|
||||
})
|
||||
end
|
||||
UIManager:close(self.histfile_dialog)
|
||||
DocumentRegistry:closeDocument(file)
|
||||
document:close()
|
||||
end
|
||||
end,
|
||||
},
|
||||
@@ -590,7 +590,7 @@ function CoverMenu:onCollectionsMenuHold(item)
|
||||
})
|
||||
end
|
||||
UIManager:close(self.collfile_dialog)
|
||||
DocumentRegistry:closeDocument(file)
|
||||
document:close()
|
||||
end
|
||||
end,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user