Giter Site home page Giter Site logo

Comments (7)

Xm4s avatar Xm4s commented on August 23, 2024

Hi!

Thanks for pointing out this!
I've looked into this bug and the problem is in your commit request.

If you reset currPageNumber to 1 only when the saved value of currPageToLoad is 0 (which in my calculation was impossible even before your contribution)... well, the chance you are resetting the variable to 1 are equal to 0 :P

I'm fixing this with the bug pointed out in the issue #36.

from baker.

Xm4s avatar Xm4s commented on August 23, 2024

Fixed with the commit b8a6d2e
As for issue #36 I'll wait for a positive feedback on the fix before closing this up.

from baker.

andreacampi avatar andreacampi commented on August 23, 2024

Well, this is different than issues #37/#38. Reproducing the problem with page 0 is probably impossible with unmodified sources (barring any bugs).

This issue however is 100% reproducible, see the steps I outlined above.

from baker.

andreacampi avatar andreacampi commented on August 23, 2024

Uhm, I saw you reverted the change that protects against currPageToLoad=0.

As I said, I agree it should never happen, but you shouldn't assume it never will.

Imagine the app was just started but we lose focus immediately (for instance, an SMS comes in) before we have even completed -initBook:
In that case, rootViewController.currentPageNumber will still be nil (it's not set in RootViewController:-init) so -saveLastPageReference will probably save lastPageViewed=0.
In that case, reading it back will get a 0 here.

Actually, in my commit I meant to protect again this particular scenario in -saveLastPageReference, but I botched it:

    if (lastPageViewed != 0) {

That's just plain wrong, sorry about that :( It should probably be:

if (rootViewController.currentPageNumber > 0) {

Anyway, the bottom line is, you should never trust that something will never happen; a bug in other parts of code may lead to this invariant not being true, and that will positively crash the app. I think you'll agree that's not nice :)

from baker.

Xm4s avatar Xm4s commented on August 23, 2024

I completely agree with you, even if it shouldn't be possible it's better to reduce any chance of the app crashing down, and in fact I didn't revert your change on lastPageView value check before saving it :)

However, as you have said here, the check as it is need a quick fix, I'll apply that as soon as I finish writing this, thanks for pointing it out.

Back to the topic of this issue, I try the step to reproduce the bug (link on page 5 a .hpub with only 3 pages) and it seems that everything works pretty well with the last commit. Could you please confirm that?

from baker.

andreacampi avatar andreacampi commented on August 23, 2024

Works for me, too. Thanks for looking at this :)

from baker.

Xm4s avatar Xm4s commented on August 23, 2024

Thank you for your precious support on the project :D
I'm closing this up.

from baker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.