Actually quit threads nicely
ClosedPublic

Authored by fvogt on Jan 20 2018, 9:26 PM.

Details

Summary

27c0245b1715044cf4d401f1c9d7e7a915a4f3c5 ("[resources] Nicely quit threads")
has no effect as the threads are not running an event loop.
Instead use the QThread::requestInterruption() mechanism.

BUG: 385533

Test Plan

kactivitymanagerd left a coredump on each logout if kate was opened
before logging out. Now it doesn't do that anymore.

Diff Detail

Repository
R161 KActivity Manager Service
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
fvogt created this revision.Jan 20 2018, 9:26 PM
Restricted Application added a project: Plasma. · View Herald TranscriptJan 20 2018, 9:26 PM
fvogt requested review of this revision.Jan 20 2018, 9:26 PM

If it's not running event loop why run is called?

fvogt added a comment.Jan 20 2018, 9:43 PM

If it's not running event loop why run is called?

That's what a QThread is:

A QThread object manages one thread of control within the program. QThreads begin executing in run(). By default, run() starts the event loop by calling exec() and runs a Qt event loop inside the thread.

lbeltrame added inline comments.
src/service/Resources.cpp
60

What's the reason for 1500 here?

src/service/plugins/sqlite/ResourceScoreMaintainer.cpp
62

Same as above.

fvogt added inline comments.Jan 21 2018, 10:39 AM
src/service/Resources.cpp
60

It's the // initial delay before processing the events plus some time for it to process the last request. I can add a comment if you want to.

lbeltrame added inline comments.Jan 21 2018, 10:51 AM
src/service/Resources.cpp
60

A comment would do (so that it is less "magic").

fvogt updated this revision to Diff 25709.Jan 21 2018, 10:58 AM

Add comments to explain the magic values

ivan added inline comments.Jan 21 2018, 11:08 PM
src/service/plugins/sqlite/ResourceScoreMaintainer.cpp
62

If that is enough, then why not just wait()?

ivan accepted this revision.Jan 21 2018, 11:11 PM

Otherwise +1

This revision is now accepted and ready to land.Jan 21 2018, 11:11 PM
This revision was automatically updated to reflect the committed changes.
fvogt added inline comments.Jan 22 2018, 7:56 AM
src/service/plugins/sqlite/ResourceScoreMaintainer.cpp
62

Simple: wait() waits for an infinite amount of time if run() never returns. If that happens (run() is stuck), we prefer a crash over silently wasting resources.