From 21b0b24b1414905b5075c39e8650af07acbef62a Mon Sep 17 00:00:00 2001 From: chrox Date: Mon, 10 Mar 2014 17:29:11 +0800 Subject: [PATCH 1/2] fix input timer queue if new timer has a timeout later than a timer in queue, the new timer will be discarded and never be pushed into timer queue. This is fixed by pushing new timer without timeout checking and then sorting the queue according to timer timeouts. This should fix #520 and #495. --- frontend/ui/input.lua | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/frontend/ui/input.lua b/frontend/ui/input.lua index d3f32e8c8..ba229bf07 100644 --- a/frontend/ui/input.lua +++ b/frontend/ui/input.lua @@ -433,15 +433,10 @@ function Input:setTimeout(cb, tv_out) callback = cb, deadline = tv_out, } - for k,v in ipairs(self.timer_callbacks) do - if v.deadline > tv_out then - table.insert(self.timer_callbacks, k, item) - break - end - end - if #self.timer_callbacks <= 0 then - self.timer_callbacks[1] = item - end + table.insert(self.timer_callbacks, item) + table.sort(self.timer_callbacks, function(v1,v2) + return v1.deadline < v2.deadline + end) end function Input:handleKeyBoardEv(ev) From 560444c1686b6a61ca65d0cc2d1b9cc5de39fdff Mon Sep 17 00:00:00 2001 From: chrox Date: Mon, 10 Mar 2014 22:06:17 +0800 Subject: [PATCH 2/2] add fallback_font option in G_reader_settings --- frontend/document/credocument.lua | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/frontend/document/credocument.lua b/frontend/document/credocument.lua index 9899ebb38..44412b528 100644 --- a/frontend/document/credocument.lua +++ b/frontend/document/credocument.lua @@ -18,9 +18,9 @@ local CreDocument = Document:new{ engine_initilized = false, line_space_percent = 100, - default_font = "FreeSerif", - header_font = "FreeSans", - fallback_font = "Droid Sans Fallback", + default_font = G_reader_settings:readSetting("cre_font") or "FreeSerif", + header_font = G_reader_settings:readSetting("header_font") or "FreeSans", + fallback_font = G_reader_settings:readSetting("fallback_font") or "Droid Sans Fallback", default_css = "./data/cr3.css", options = CreOptions, } @@ -56,16 +56,6 @@ function CreDocument:engineInit() end end - local default_font = G_reader_settings:readSetting("cre_font") - if default_font then - self.default_font = default_font - end - - local header_font = G_reader_settings:readSetting("header_font") - if header_font then - self.header_font = header_font - end - engine_initilized = true end end