Arrow-key navigation crashes when a track header is selected

Open Beginner friendly
#9 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
desktop

Research direction

Start in the keyPressEvent() handler and _get_first_item(), where the arrow-key navigation picks its starting item and filters the selection. Reproduce by selecting a track header (track_widgets.TrackNameItem) and pressing Left or Right, which should raise the AttributeError on a None item. Done means navigation skips track headers and ignores items whose .item is None, and an empty timeline returns None without error.

Written by the indexing model from the issue text.

Description

Arrow-key navigation crashes when a track header is selected

Steps to reproduce:

  1. Open a timeline containing clips.
  2. Click a track header on the left.
  3. Press Left or Right, without modifiers.

This raises:

AttributeError: 'NoneType' object has no attribute 'parent'

Clearing the selection and pressing Right twice also reproduced the issue: the first press selected a track header, and the second crashed.

TrackNameItem inherits BaseItem, but its .item is None. It passes the navigation type check, leading to otio_item.parent() being called on None.

Proposed fix

  1. Replace _get_first_item() with a lookup of valid timeline items, avoiding fixed-coordinate hit testing:
    def _get_first_item(self):
        return min(
            (item for item in self.scene().items() if isinstance(item, track_widgets.BaseItem) and item.item is not None),
            key=lambda item: (item.scenePos().y(), item.scenePos().x()),
            default=None,
        )
  1. In keyPressEvent(), exclude track headers as well as the ruler:
        selections = [
            x for x in self.scene().selectedItems()
            if not isinstance(x, (ruler_widget.Ruler, track_widgets.TrackNameItem))
        ]

With these changes, navigation starts from a valid timeline item when no clip is selected, while empty timelines safely return None.

Dominant language
Python
Stars
2
Forks
3
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from OpenTimelineIO/otioview

All issues in OpenTimelineIO/otioview

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.