fix: use deleteLater for network objects and order them (#5297)

This commit is contained in:
nerix 2024-04-03 21:08:52 +02:00 committed by GitHub
parent 8db0bb464d
commit 2ea24c1a9d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 4 deletions

View file

@ -201,7 +201,7 @@
- Dev: Refactor `StreamerMode`. (#5216, #5236)
- Dev: Cleaned up unused code in `MessageElement` and `MessageLayoutElement`. (#5225)
- Dev: Adapted `magic_enum` to Qt's Utf-16 strings. (#5258)
- Dev: `NetworkManager`'s statics are now created in its `init` method. (#5254)
- Dev: `NetworkManager`'s statics are now created in its `init` method. (#5254, #5297)
- Dev: `clang-tidy` CI now uses Qt 6. (#5273)
- Dev: Enabled `InsertNewlineAtEOF` in `clang-format`. (#5278)

View file

@ -24,15 +24,19 @@ void NetworkManager::deinit()
assert(NetworkManager::workerThread);
assert(NetworkManager::accessManager);
// delete the access manager first:
// - put the event on the worker thread
// - wait for it to process
NetworkManager::accessManager->deleteLater();
NetworkManager::accessManager = nullptr;
if (NetworkManager::workerThread)
{
NetworkManager::workerThread->quit();
NetworkManager::workerThread->wait();
}
delete NetworkManager::accessManager;
NetworkManager::accessManager = nullptr;
delete NetworkManager::workerThread;
NetworkManager::workerThread->deleteLater();
NetworkManager::workerThread = nullptr;
}