baskerville / plato

Document reader
Other
1.27k stars 108 forks source link

Crash on named page #76

Closed 7596ff closed 4 years ago

7596ff commented 4 years ago

I'm having a crash with a few different books, but this one is reproducible. When I highlight a text selection and annotate it, trying to go to the next page crashes the application. Here is my crash.log:

Plato is running on a Kobo Aura H₂O Edition 2.
The framebuffer resolution is 1080 by 1440.
Philosophy/Georg Wilhelm Fredrich Hegel, Terry Pinkard/Phenomenology of Spirit, The - Georg Wilhelm Fredrich Hegel, Terry Pinkard ().pdf
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', /rustc/4560ea788cb760f0a34127156c78e2552949f734/src/libcore/slice/mod.rs:2717:10
stack backtrace:
   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: <unknown>
   2: <unknown>
   3: <unknown>
  ...snip...
  20: <unknown>
  21: <unknown>
  22: main
  23: __libc_start_main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Here is a copy of the PDF that I am reading: https://plato.is-pretty.cool/2HW3enF.pdf

baskerville commented 4 years ago

I can't reproduce. Could you provide the entry in .metadata.json associated with this book?

7596ff commented 4 years ago
  {
    "title": "The Phenomenology of Spirit",
    "author": "Georg Wilhelm Frederich Hegel",
    "categories": [
      "Philosophy.Georg Wilhelm Fredrich Hegel, Terry Pinkard"
    ],
    "file": {
      "path": "Philosophy/Georg Wilhelm Fredrich Hegel, Terry Pinkard/Phenomenology of Spirit, The - Georg Wilhelm Fredrich Hegel, Terry Pinkard ().pdf",
      "kind": "pdf",
      "size": 2773557
    },
    "reader": {
      "opened": "2019-12-03 13:55:17",
      "currentPage": 44,
      "pagesCount": 538,
      "finished": false,
      "rotation": 1,
      "pageNames": {
        "46": "1"
      },
      "annotations": [
        {
          "text": "“Sache” (as a “thing”) and a “Ding ”(as a more “thingy” thing).",
          "selection": [
            [
              44,
              50
            ],
            [
              44,
              61
            ]
          ],
          "modified": "2019-12-03 14:50:11"
        },
        {
          "text": "“thing” in the sense of hipster sixties lingo (as in, “Do your own thing”) might work,",
          "selection": [
            [
              44,
              67
            ],
            [
              44,
              82
            ]
          ],
          "modified": "2019-12-03 14:50:47"
        }
      ]
    },
    "added": "2019-04-24 08:29:52"
  },
7596ff commented 4 years ago

Okay, the issue resides in trying to move to a named page. The page that the reader display shows is 45, but since pages are 0-indexed in code, it is 44. Going to the next page (45 in the code, 46 logically) is the crash. The same thing happens when going from logical page 47 to 46.