mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Make sure KindlePowerD's __gc metamethod will actually be called
* Via the newproxy hack.
This commit is contained in:
@@ -125,13 +125,19 @@ function KindlePowerD:isChargingHW()
|
||||
return is_charging == 1
|
||||
end
|
||||
|
||||
function KindlePowerD:__gc()
|
||||
local KindlePowerD_mt = {}
|
||||
function KindlePowerD_mt:__gc()
|
||||
if self.lipc_handle then
|
||||
self.lipc_handle:close()
|
||||
self.lipc_handle = nil
|
||||
end
|
||||
end
|
||||
|
||||
-- Funky ass newproxy() workaround to make __gc work on a plain table in Lua 5.1/LuaJIT
|
||||
-- c.f., https://github.com/katlogic/__gc
|
||||
local setmetatable = require("ffi/__gc")
|
||||
setmetatable(KindlePowerD, KindlePowerD_mt)
|
||||
|
||||
function KindlePowerD:_readFLIntensity()
|
||||
return self:read_int_file(self.fl_intensity_file)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user