QcepObject::~QcepObject() { #ifndef QT_NO_DEBUG QThread *currTh = QThread::currentThread(); QThread *objTh = thread(); if (objTh && currTh != objTh) { printf("Deleting object from different thread %s (%s, %s)\n", qPrintable(objectName()), qPrintable(currTh ? currTh->objectName() : "null"), qPrintable(objTh ? objTh->objectName() : "null")); } #endif s_ObjectDeleteCount.fetchAndAddOrdered(1); #ifndef QT_NO_DEBUG s_Allocated.remove(this); #endif }
void toSetThreadName(QThread const& p) { // This was copied from QT trunk - as of 4.8.2 it is not used yet QByteArray objectName = p.objectName().toLatin1(); if (objectName.isEmpty()) objectName = p.metaObject()->className(); #if defined(__linux__) prctl(PR_SET_NAME, (unsigned long)objectName.constData(), 0, 0, 0); #elif defined(Q_OS_MAC) pthread_setname_np(objectName.constData()); #endif }
void Application::reportException(QString text) { QThread* main = this->thread(); QThread* current = QThread::currentThread(); QString threadName = current->objectName(); if (threadName.isEmpty()) { if (main==current) threadName = "MAIN"; else threadName = "SECONDARY"; } reportError(QString("Exception caught: [%1]\nin thread [%2]").arg(text).arg(threadName)); }