Skip to content

[fix] Empty directory path and crash on TextWidget#5606

Merged
Frenzie merged 5 commits intokoreader:masterfrom
robert00s:empty_path
Nov 19, 2019
Merged

[fix] Empty directory path and crash on TextWidget#5606
Frenzie merged 5 commits intokoreader:masterfrom
robert00s:empty_path

Conversation

@robert00s
Copy link
Copy Markdown
Contributor

PR fix prevent empty path in filemanager.

obraz

Step to reproduce:

  1. Create two folders:
  • /home/koreader/test
  • /home/koreader/test1
  1. Set folder /home/koreader/test as home folder in KO
  2. Set option Shorten home directory (Other settings -> Shorten home directory)
  3. Go to folder in fm to /home/koreader/test1

@Frenzie Frenzie added the bug label Nov 18, 2019
@Frenzie Frenzie added this to the 2019.12 milestone Nov 18, 2019
@poire-z
Copy link
Copy Markdown
Contributor

poire-z commented Nov 18, 2019

@robert00s just a quick note. We added something this weekend #5598 (comment) - so TextWidget will crash (on the emulator only) when it doesn't get a string for text = - a number for example.
I pinpoint up to now a single place that needs a fix:

--- a/frontend/ui/widget/bookstatuswidget.lua
+++ b/frontend/ui/widget/bookstatuswidget.lua
@@ -138,5 +138,5 @@ end
 function BookStatusWidget:getStatDays()
     if stats_book.days then
-        return stats_book.days
+        return tostring(stats_book.days)
     else
         return _("N/A")

(feel free to add this quick one to this PR).
There's much of your code/widgets that I don't usually visit (but Reading statictics seems ok), so, if you can have a quick check that nothing else crashes, that'd be nice :)

@robert00s
Copy link
Copy Markdown
Contributor Author

@poire-z
I also notice a few minutes ago a problem with BookStatusWidget. I'll add your patch soon.
I have a quick check too.

@robert00s robert00s changed the title [fix] Empty directory path [fix] Empty directory path and crash on TextWidget Nov 18, 2019
@robert00s
Copy link
Copy Markdown
Contributor Author

Ok, I found crash on ReadingProgress. PR soon.

@poire-z
Copy link
Copy Markdown
Contributor

poire-z commented Nov 18, 2019

(Just pointing another one I found - not opening another PR, if you can add it here, hope that's ok :)

--- a/frontend/apps/reader/skimtowidget.lua
+++ b/frontend/apps/reader/skimtowidget.lua
@@ -187,3 +187,3 @@ function SkimToWidget:init()
     self.current_page_text = Button:new{
-        text = self.curr_page,
+        text = tostring(self.curr_page),
         bordersize = 0,

@poire-z
Copy link
Copy Markdown
Contributor

poire-z commented Nov 19, 2019

Thanks, and sorry, another one in that same file:

--- a/frontend/apps/reader/skimtowidget.lua
+++ b/frontend/apps/reader/skimtowidget.lua
@@ -367,3 +367,3 @@ function SkimToWidget:update()
     self.progress_bar.percentage = self.curr_page / self.page_count
-    self.current_page_text:setText(self.curr_page, self.current_page_text.width)
+    self.current_page_text:setText(tostring(self.curr_page), self.current_page_text.width)
 end

@robert00s
Copy link
Copy Markdown
Contributor Author

No problem :)

@Frenzie Frenzie merged commit 03fda96 into koreader:master Nov 19, 2019
@robert00s robert00s deleted the empty_path branch November 23, 2019 18:13
mwoz123 pushed a commit to mwoz123/koreader that referenced this pull request Mar 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants