Fix timer errors on exit

The NetworkRemote is moved to a new thread after creation. On that thread, its
child classes create timers. When the network remote class is deleted on the
main thread, we see "Timers cannot be stopped from another thread".

To avoid this error, use deleteLater to delete NetworkRemote and its composition
classes on its own thread.
This commit is contained in:
Jim Broadus 2020-05-18 23:56:21 -07:00 committed by John Maguire
parent 5b918a70aa
commit 8f56fbb83b
1 changed files with 9 additions and 5 deletions

View File

@ -142,11 +142,15 @@ class ApplicationImpl {
return nullptr;
#endif
}),
network_remote_([=]() {
NetworkRemote* remote = new NetworkRemote(app);
app->MoveToNewThread(remote);
return remote;
}),
// Since NetworkRemote is moved to a different thread and creates
// timers there, it should also be deleted on that thread.
network_remote_(
[=]() {
NetworkRemote* remote = new NetworkRemote(app);
app->MoveToNewThread(remote);
return remote;
},
[=](NetworkRemote* remote) { remote->deleteLater(); }),
network_remote_helper_([=]() { return new NetworkRemoteHelper(app); }),
scrobbler_([=]() {
#ifdef HAVE_LIBLASTFM