Skip to content

Ctrl+Scroll zoom crashes with "ValueError: too many values to unpack (expected 2)" #21

Description

@ikabrain

Hello contributors, this is a small but crucial bug.

While I was testing PR #20 by injecting failure points, I noticed that focal-point zoom (holding Ctrl while scrolling) does not work at all.

What I did

Launched the app from a terminal so stderr would be visible, opened a PDF, then held Ctrl and scrolled the wheel over the page.

python3 -m inlinea          # ran from terminal so traceback is visible
# open any PDF, then hold Ctrl and scroll the mouse wheel over the page

What happened

The page never zooms, and the terminal prints:

Traceback (most recent call last):
  File ".../src/inlinea/ui/pdf_view.py", line 774, in on_scroll
    sx, sy = event.get_position()
    ^^^^^^
ValueError: too many values to unpack (expected 2)

It reproduces every time. Because the error only surfaces from a terminal launch, a user who started Inlinea from the desktop icon would just see a broken zoom with no clue why.

Why does this happen?

In on_scroll (src/inlinea/ui/pdf_view.py:774), the Ctrl branch does sx, sy = event.get_position(). Under PyGObject, Gdk.Event.get_position() returns a three-value tuple, (bool, float, float): a success flag followed by the x and y coordinates . Unpacking that into two names raises the ValueError, which aborts the handler before it ever reaches _zoom_around_focal() a few lines down, so no zoom occurs. Interestingly, the very similar call two lines later, success, pt = native.compute_point(...), already handles the flag correctly, so this looks like a single spot that got missed rather than a pattern-wide issue.

I expected Ctrl+Scroll to zoom centered on the cursor; instead nothing changes on screen.

Happy to open a small PR to add the tiny changes that'll:

  1. Read the success flag that get_position() returns so the unpacking matches the value's real shape, and
  2. Fall back to the existing center-of-viewport focal point that on_scroll already computes when an event carries no usable position, so cursor-centered zoom keeps working in the normal case and errors out gracefully otherwise.

Happy to leave it alone if you'd rather take it yourself, or if a larger rework of the zoom path is already on your plate. Just let me know, and thanks again!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions