void LockMonitor::add(const char *file, size_t line,
                      epicsThreadId thread, OrderedMutex &lock)
{
    epicsMutexGuard guard(mutex);
    // Add lock to the list of locks for that thread.
    stdList<ThreadList>::iterator i;
    for (i = threads.begin();  i != threads.end();  ++i)
    {
        if (i->getThread() == thread)
        {
            if (!i->add(&lock))
            {
                fprintf(stderr, "=========================================\n");
                fprintf(stderr, "Violation of lock order in\n");
                fprintf(stderr, "file %s, line %zu:\n\n", file, line);
                dump(guard);
                fprintf(stderr, "=========================================\n");
                // Remove the offending one, since we won't lock it
                i->remove(&lock);
                if (getenv("ABORT_ON_ERRORS"))
                {
                    LOG_MSG("%s (%zu): Violation of lock order\n",
                            file, line);
                    abort();
                }
                // else
                throw GenericException(file, line, "Violation of lock order");
            }
            return;
        }
    }
    threads.push_back(ThreadList(thread, &lock));
}
void AddNoteDialog::setThread( const Thread & thread )
{
	mThread = thread;
	setSubject( mThread.topic() );
	setElement( mThread.element() );
	setJobs( ThreadList(mThread.job()) );
	setBody( mThread.body() );
	appendList( mThread.threadNotifies().users() );
    if( mThread.isRecord() )
        mAttachmentList->addItems( mThread.attachmentFiles() );
    mReplyThread = mThread.reply();
}