Skip to content

Keep the previous and next comic actions after a file fails to open - #630

Merged
luisangelsm merged 3 commits into
YACReader:developfrom
wonjoonSeol:fix/prev-next-after-unreadable-comic
Nov 6, 2026
Merged

luisangelsm merged 3 commits into
YACReader:developfrom
wonjoonSeol:fix/prev-next-after-unreadable-comic

Conversation

@wonjoonSeol

Copy link
Copy Markdown
Contributor

Fixes #626.

Problem

When a comic opened from the file system can't be read, the error is shown and after that the previous and next comic shortcuts (default Ctrl+Left/Right, shortcuts_manager.cpp#L41-L42) do nothing, so the reader can't move on to the next file in the folder.

Screenshots

Linux build run offscreen with generated sample pages, taken on my fork, which carries the first commit of this PR. "Upstream" runs the same steps on develop at 268288b.

A folder with Comic 1.pdf, an unreadable Comic 2.cbz and Comic 3.pdf. Going from Comic 1 to the next comic shows:

Format not supported error

After closing the error:

Previous / next comic buttons
Upstream Both buttons greyed out
This PR Both buttons available

With this PR, the next comic action (Ctrl+Right) then opens Comic 3:

Comic 3 open at its first page

Cause

A failed open resets the viewer, and the reset ends in MainWindowViewer::processReset:

resetContent emits reset (viewer.cpp#L1821), which is connected to processReset (main_window_viewer.cpp#L248). For comics not opened from the library, processReset always disables the previous and next comic actions (main_window_viewer.cpp#L1340-L1345), although the neighbouring files were already found when the comic was opened (openComic calls getSiblingComics, #L1023 and #L1685-L1692).

Change

  • processReset now sets the previous and next comic actions from the neighbouring comics, with the code MainWindowViewer::doubleMangaPageSwitch already had (main_window_viewer.cpp#L1522-L1530). That function only works out those two actions, so it is renamed to refreshPrevNextActions and its two callers use the new name (#L183, #L519). For comics opened from the library the reset now works the actions out from the sibling list, the same way open does (#L971-L972), instead of leaving them as they were. The offscreen run below gives the same result as upstream there.
  • The third way into processReset is opening a recent file that no longer exists (main_window_viewer.cpp#L920-L923). There the neighbours still belong to the comic that was open before, while the view shows "Press 'O' to open comic.", so the PR clears previousComicPath and nextComicPath first and the actions stay disabled as before. In library mode this path behaves as before.

Relation to #614

#614 replaces siblingComics.indexOf(currentComicDB) in doubleMangaPageSwitch with currentSiblingIndex, and this PR renames that function. The two don't conflict: git merge-tree of this branch with #614's head (e0711b3) merges cleanly, and refreshPrevNextActions keeps the currentSiblingIndex version. If #614 lands first and you'd rather have this rebased onto it, I'm happy to do that.

Testing

  • Builds on Linux (WSL Ubuntu, Qt 6.10.2, -DPDF_BACKEND=poppler).
  • CI on my fork, with the same build.yml plus one line adding workflow_dispatch so it can be started by hand: run 40144752327. Every job passed: Code Format Validation, Linux (Qt6 + libarchive), Linux (Qt6 + 7zip), macOS (Qt6 Universal), Windows x64 (Qt6), Windows ARM64 (Qt6), Docker amd64 and arm64 images, and Source Tarball. The Linux, macOS and Windows x64 jobs also run ctest.
  • No automated test: nothing in tests/ sets up MainWindowViewer.
  • Offscreen run of the Linux build with a small harness (not part of this PR) that drives MainWindowViewer and reads both actions and their toolbar buttons. The folder holds Comic 1.pdf, an unreadable Comic 2.cbz, Comic 3.pdf, Comic 4.pdf and an unreadable Comic 5.cbz. "Upstream" is the same run on develop at 268288b.
Step Upstream This PR
Comic 1, next comic, close "Format not supported" both disabled both enabled
Next comic again nothing happens Comic 3 opens
From Comic 3, previous comic (error), previous comic again (not reached) Comic 1 opens
Manga mode, Comic 4, next comic (Comic 5.cbz is the last file and fails) both disabled only previous (right in manga mode) enabled, and it opens Comic 4
Comic 3 open, then a recent file that was deleted both disabled both disabled
Library mode, list [Comic 2.cbz, Comic 4.pdf], Comic 2.cbz fails only next enabled only next enabled
Library mode, then a recent file that was deleted only next enabled only next enabled

The library rows set isClient and the sibling list directly in the harness, since the real path needs YACReaderLibrary running. The folder neighbours left over from the earlier rows give both directions there, so these rows show that the reset reads the library list. Two mutations fail the run as expected: reading the folder neighbours in library mode breaks the library rows, and dropping the line that clears the paths in openComicFromRecentAction breaks the deleted recent file row.

Manual checks still to do:

  • A corrupt .cbz between two good comics in a folder: open the first, Ctrl+Right, close the error, Ctrl+Right opens the third.
  • The same in manga mode (the directions swap).
  • From YACReaderLibrary, with an unreadable comic between two good ones.
  • Open recent with a file that no longer exists: "Comic not found", and both actions stay disabled.

wonjoonSeol added a commit to wonjoonSeol/yacreader that referenced this pull request Oct 25, 2026
Thirteen changes, with a Kind column of Option, Feature or Bug fix and an App column, since rating spans both apps and folder comics are a library change. The PR column says which PRs are closed previews, open, drafts or upstream, and links the two bug fixes' upstream PRs (YACReader#629, YACReader#630). Bicubic and Lanczos3/Lanczos2 become one Scaling methods section with one measurement table, from the numbers in both branches' READMEs. Adds short sections for the background scaling (from PR #13) and the clipped status message fix, makes the menu's scaling row match the six methods, and notes that each change's screenshots come from its own branch.
When a comic opened from the file system could not be read, the reset
that follows the error disabled the previous and next comic actions, so
the shortcuts could not move on to the neighbouring files. The reset now
updates those actions the same way the double manga page switch does.
The previous commit moved the body of doubleMangaPageSwitch into a new
updatePrevNextActions() overload and left doubleMangaPageSwitch only
forwarding to it. That overload shares its name with
updatePrevNextActions(bool, bool) but works the state out instead of
applying it. Since doubleMangaPageSwitch never did more than this, the
two become one function, refreshPrevNextActions, in the place
doubleMangaPageSwitch had, and every caller uses it.
…ssing

Opening a recent file that no longer exists also resets the viewer, and
the reset now sets the actions from the neighbours of the comic that was
open before, while no comic is shown. Forgetting those neighbours first
keeps the actions disabled there, as before, for comics not opened from
the library. For comics opened from the library the reset works the
actions out from the sibling list, so nothing changes there.
@luisangelsm
luisangelsm force-pushed the fix/prev-next-after-unreadable-comic branch from 129cebe to be3ba43 Compare November 6, 2026 14:03
@luisangelsm
luisangelsm merged commit fde1102 into YACReader:develop Nov 6, 2026
13 checks passed
@luisangelsm

Copy link
Copy Markdown
Member

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Previous/next comic shortcuts stop working after a file fails to open

2 participants