Name all threads created by Application

In Application::MoveToNewThread, name the new thread after the object being
moved. Give those objects names as well.

The thread names display in gdb with "info threads".
This commit is contained in:
Jim Broadus 2020-05-26 22:36:26 -07:00 committed by John Maguire
parent 5612c9cb5d
commit 84099f2491
6 changed files with 11 additions and 2 deletions

View File

@ -226,6 +226,8 @@ Application::~Application() {
void Application::MoveToNewThread(QObject* object) {
QThread* thread = new QThread(this);
if (!object->objectName().isEmpty())
thread->setObjectName(object->objectName() + " thread");
MoveToThread(object, thread);

View File

@ -215,6 +215,7 @@ Database::Database(Application* app, QObject* parent,
injected_database_name_(database_name),
query_hash_(0),
startup_schema_version_(-1) {
setObjectName("Database");
{
QMutexLocker l(&sNextConnectionIdMutex);
connection_id_ = sNextConnectionId++;

View File

@ -34,6 +34,7 @@ TagReaderClient* TagReaderClient::sInstance = nullptr;
TagReaderClient::TagReaderClient(QObject* parent)
: QObject(parent), worker_pool_(new WorkerPool<HandlerType>(this)) {
sInstance = this;
setObjectName("Tag reader client");
QSettings s;
s.beginGroup(Player::kSettingsGroup);

View File

@ -43,7 +43,9 @@ AlbumCoverLoader::AlbumCoverLoader(QObject* parent)
stop_requested_(false),
next_id_(1),
network_(new NetworkAccessManager(this)),
connected_spotify_(false) {}
connected_spotify_(false) {
setObjectName("Album cover loader");
}
QString AlbumCoverLoader::ImageCacheDir() {
return Utilities::GetConfigPath(Utilities::Path_AlbumCovers);

View File

@ -42,6 +42,7 @@ PodcastDeleter::PodcastDeleter(Application* app, QObject* parent)
backend_(app_->podcast_backend()),
delete_after_secs_(0),
auto_delete_timer_(new QTimer(this)) {
setObjectName("Podcast deleter");
ReloadSettings();
auto_delete_timer_->setSingleShot(true);
AutoDelete();

View File

@ -35,7 +35,9 @@ const quint16 NetworkRemote::kDefaultServerPort = 5500;
const char* NetworkRemote::kTranscoderSettingPostfix = "/NetworkRemote";
NetworkRemote::NetworkRemote(Application* app, QObject* parent)
: QObject(parent), signals_connected_(false), app_(app) {}
: QObject(parent), signals_connected_(false), app_(app) {
setObjectName("Network remote");
}
NetworkRemote::~NetworkRemote() { StopServer(); }