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