diff --git a/reader.lua b/reader.lua index a80218887..2b0ddb668 100755 --- a/reader.lua +++ b/reader.lua @@ -17,8 +17,6 @@ end local DocSettings = require("docsettings") local _ = require("gettext") -local util = require("ffi/util") - -- read settings and check for language override -- has to be done before requiring other files because -- they might call gettext on load @@ -28,31 +26,6 @@ if lang_locale then _.changeLang(lang_locale) end -local lfs = require("libs/libkoreader-lfs") -local UIManager = require("ui/uimanager") -local Device = require("device") -local Screen = require("device").screen -local input = require("ffi/input") -local DEBUG = require("dbg") - -local Profiler = nil - -local function exitReader() - local ReaderActivityIndicator = require("apps/reader/modules/readeractivityindicator") - - G_reader_settings:close() - - -- Close lipc handles - ReaderActivityIndicator:coda() - - -- shutdown hardware abstraction - Device:exit() - - if Profiler then Profiler.stop() end - os.exit(0) -end - - -- option parsing: local longopts = { debug = "d", @@ -78,6 +51,11 @@ local function showusage() return end +-- should check DEBUG option in arg and turn on DEBUG before loading other +-- modules, otherwise DEBUG in some modules may not be printed. +local DEBUG = require("dbg") + +local Profiler = nil local ARGV = arg local argidx = 1 while argidx <= #ARGV do @@ -104,6 +82,12 @@ while argidx <= #ARGV do end end +local lfs = require("libs/libkoreader-lfs") +local UIManager = require("ui/uimanager") +local Device = require("device") +local Screen = require("device").screen +local Font = require("ui/font") + -- read some global reader setting here: -- font local fontmap = G_reader_settings:readSetting("fontmap") @@ -160,4 +144,19 @@ else return showusage() end +local function exitReader() + local ReaderActivityIndicator = require("apps/reader/modules/readeractivityindicator") + + G_reader_settings:close() + + -- Close lipc handles + ReaderActivityIndicator:coda() + + -- shutdown hardware abstraction + Device:exit() + + if Profiler then Profiler.stop() end + os.exit(0) +end + exitReader()