DocumentRegistry: Downgrade refcount warnings to debug logging.

It can happen in perfectly sane contexts.

CReDocument: Don't destroy internal engine data when Document just
decreased the refcount (as opposed to actually tore down the document
userdata if it were the last ref).

PdfDocument: Only write edited documents if the Doc instance was torn
down.

PicDocument: Silence some DocumentRegistry related warnings
This commit is contained in:
NiLuJe
2021-05-20 19:09:54 +02:00
parent 7dea979ef4
commit 2c4cbd12a2
6 changed files with 48 additions and 19 deletions

View File

@@ -305,12 +305,20 @@ function CreDocument:_readMetadata()
end
function CreDocument:close()
if self.buffer then
self.buffer:free()
self.buffer = nil
end
-- Let Document do the refcount check, and tell us if we actually need to tear down the instance.
if Document.close(self) then
-- Yup, final Document instance, we can safely destroy internal data.
-- (Document already took care of our self._document userdata).
if self.buffer then
self.buffer:free()
self.buffer = nil
end
Document.close(self)
-- Only exists if the call cache is enabled
if self._callCacheDestroy then
self._callCacheDestroy()
end
end
end
function CreDocument:updateColorRendering()
@@ -1742,12 +1750,6 @@ function CreDocument:setupCallCache()
if do_stats then
self.close = function(_self)
dumpStats()
_self._callCacheDestroy()
CreDocument.close(_self)
end
else
self.close = function(_self)
_self._callCacheDestroy()
CreDocument.close(_self)
end
end