From 1b1e65edfed02f3a5a99dcde3eefb3f28dde914e Mon Sep 17 00:00:00 2001 From: Paulo Matias Date: Fri, 17 Jan 2014 16:41:44 -0200 Subject: [PATCH] Avoid crash if trying to open a non-existent file which currently might occur by clicking in the history entry of a file which was removed --- reader.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/reader.lua b/reader.lua index 03859c327..8928a8b01 100755 --- a/reader.lua +++ b/reader.lua @@ -50,6 +50,12 @@ end function showReaderUI(file, pass) DEBUG("opening file", file) + if lfs.attributes(file, "mode") ~= "file" then + UIManager:show(InfoMessage:new{ + text = _("File does not exist") + }) + return + end UIManager:show(InfoMessage:new{ text = _("opening file") .. file, timeout = 1, @@ -172,11 +178,11 @@ end if ARGV[argidx] and ARGV[argidx] ~= "" then if lfs.attributes(ARGV[argidx], "mode") == "directory" then showHomePage(ARGV[argidx]) - elseif lfs.attributes(ARGV[argidx], "mode") == "file" then + else showReaderUI(ARGV[argidx]) end UIManager:run() -elseif last_file and lfs.attributes(last_file, "mode") == "file" then +elseif last_file then showReaderUI(last_file) UIManager:run() else