Exemplo n.º 1
0
// check the constructor's parent thread arguments
bool QObject::check_parent_thread(QObject *parent, QThreadData *parentThreadData, QThreadData *currentThreadData)
{
  if (parent && parentThreadData != currentThreadData) {

      QThread *parentThread  = parentThreadData->thread;
      QThread *currentThread = currentThreadData->thread;

      qWarning("QObject:check_parent_thread() Can not create children for a parent in a different thread.\n"
               "(Parent is %s(%p), parent's thread is %s(%p), current thread is %s(%p)",
               parent->metaObject()->className(), parent,
               parentThread ? parentThread->metaObject()->className() : "QThread",
               parentThread, currentThread ? currentThread->metaObject()->className() : "QThread", currentThread);

      return false;
  }

  return true;
}
Exemplo n.º 2
0
    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
    }