Fix many threading issues in KUrlCompletion

Review Request #127437 - Created March 20, 2016 and submitted

David Faure

* Major race with other threads due to using QDir::setCurrent()
* Race conditions on m_terminationRequested and m_matches
* Race with previous completion thread when its posted event arrives after cancelling
* Cancellation code spread out in many methods and never done fully correctly
* isRunning() was missing one of the two threads, making unit test fail in valgrind
* Fix the rarely-hit code path where the thread isn't finished after 200ms
- the current search string was lost because finished() wasn't called
- the matches were not used, in case of user-completion (AFAICS)
- changing the search string while the thread was running could lead to the old search
string still being used for completion
(the misnamed finished() wasn't called, so KCompletion didn't get the new string)
=> added a variant of the unittest which doesn't wait for the thread initially

+ Simplify code using signal/slots rather than a custom event
+ Simplify code using enum rather than casting to/from int

Most of these bugs are from 2004 (e.g. commit ec83c408619e3) ;)

REVIEW: 127437

Hit a crash in DirectoryListThread when playing with kopenwithtest.

kurlcompletiontest extended, kurlcompletion-nowait added, both pass, also in valgrind (different timings).


  • 0
  • 0
  • 1
  • 1
Description From Last Updated
David Faure
David Edmundson
David Edmundson
David Faure
Review request changed

Status: Closed (submitted)

Change Summary:

Submitted with commit 15fd9b17eb2f4d686891d2364e698e40260f9131 by David Faure to branch master.