Ref T314, thread CContinuousWorker::finish

- use application thread if there is no owner
- use QPointer for owner
- more detailled error message
This commit is contained in:
Klaus Basan
2018-08-30 01:17:14 +02:00
parent f6dee9e7ff
commit 5096df034b
5 changed files with 70 additions and 26 deletions

View File

@@ -31,6 +31,12 @@ namespace BlackMisc
return (QCoreApplication::instance()->thread() == toBeTested->thread());
}
bool CThreadUtils::isApplicationThread(const QThread *toBeTested)
{
if (!toBeTested || !QCoreApplication::instance() || !QCoreApplication::instance()->thread()) { return false; }
return (QCoreApplication::instance()->thread() == toBeTested);
}
bool CThreadUtils::isCurrentThreadApplicationThread()
{
if (!QCoreApplication::instance()) { return false; }
@@ -68,11 +74,15 @@ namespace BlackMisc
return s.arg(reinterpret_cast<long long>(t), 0, 16);
}
const QString CThreadUtils::currentThreadInfo()
const QString CThreadUtils::threadInfo(QThread *thread)
{
static const QString info("thread: %1 name: '%2' priority: '%3'");
const QThread *t = QThread::currentThread();
if (!t) { return QString("no thread"); }
return info.arg(threadToString(t), t->objectName(), priorityToString(t->priority()));
if (!thread) { return QString("no thread"); }
return info.arg(threadToString(thread), thread->objectName(), priorityToString(thread->priority()));
}
const QString CThreadUtils::currentThreadInfo()
{
return threadInfo(QThread::currentThread());
}
} // ns