Skip to content

Fix QScroller crash on Qt < 5.14 and certain screen arrangements

QScrollerPrivate::setDpiFromWidget() before Qt 5.14 crashes when the target widget does not intersect a physical screen, because QDesktopWidget returns screen index -1 in this case, which leads to an out-of-range read from QApplication::screens(), which leads to a segfault when reading from an invalid QScreen* pointer.

This adds a workaround that checks for the -1 situation, and then tries to resize PageView temporarily to intersect at least some screen.

BUG: 425188 FIXED-IN: 20.12

Test plan

  1. Get someone with two screens and Qt < 5.14
  2. Arrange screens corner-corner topright-bottomleft, so you have dead space at the top-left of (0, 0, 1000x800) or bigger.
  3. Okular 20.04.0 ... 20.08.3 should crash when launching from Dolphin or when opening a second tab.
  4. Compile Okular with this patch.
  5. Patched Okular should not crash.

Merge request reports