D7595: Skip reload when another reload is already in progress
Henrik Fehlauer
noreply at phabricator.kde.org
Mon Aug 28 23:34:10 UTC 2017
rkflx created this revision.
Restricted Application added a project: Okular.
REVISION SUMMARY
When pressing and holding [F5], Okular would reload the current
document multiple times and eventually get stuck with no document
showing and the "Reloading the document..." message reappearing every
second in an infinite loop. On exit, Okular then would sometimes
segfault, although often in different lines of code.
These issues can be avoided by only allowing one reload progressing at
any time. Any further reload requests are discarded.
Implementation:
- use std::unique_lock, as QMutexLocker lacks support for try_lock
- use std::mutex, as QMutex supports try_lock only since Qt 5.8
Note: The "Reload" menu entry and shortcut are already disabled while
fetching the document (most noticable when using a slow network link).
The new lock protects against *overlapping* reload requests coming in
after fetching completes but before rendering finishes.
Thanks to @aacid for finding the fix, this merely improves the
implementation by using a mutex with RAII instead of a non-atomic and
non-dry boolean.
TEST PLAN
- Builds with both GCC 4.8 / Qt 5.6 and GCC 7.1 / Qt 5.9.
- No hiccups and crashes anymore when holding [F5].
- Behaviour for slow downloading remote documents unchanged.
REPOSITORY
R223 Okular
BRANCH
reload-mutex (branched from Applications/17.08)
REVISION DETAIL
https://phabricator.kde.org/D7595
AFFECTED FILES
part.cpp
part.h
To: rkflx, #okular
Cc: aacid
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/okular-devel/attachments/20170828/95a34993/attachment-0001.html>
More information about the Okular-devel
mailing list