I guess they are.

This is the function which gets called after the thread has changed the data ( m_can[i] ), the thread emits scrolltable function which ends up calling the code below:

Qt Code:
  1. void DATreeModel::setCanData( int nAmount, int nCount )
  2. {
  3. int row = rowCount();
  4.  
  5. beginInsertRows(QModelIndex(), row, row + nAmount - 1 ); // insert nAmount of rows
  6.  
  7. QMutex mutex;
  8. mutex.lock();
  9.  
  10. for( int i = 0; i < nAmount; i++ )
  11. {
  12. m_Data.append(m_can[i].strId);
  13. m_Data.append(m_can[i].strTime);
  14. m_Data.append(m_can[i].strData);
  15. QString strCount;
  16. strCount.sprintf( "%i", nCount );
  17. m_Data.append(strCount);
  18. nCount++;
  19.  
  20. }
  21. mutex.unlock();
  22.  
  23. endInsertRows();
  24. }
To copy to clipboard, switch view to plain text mode 

This is the thread code :

Qt Code:
  1. void CanRead::run()
  2. {
  3. m_nCount = 0;
  4.  
  5. m_bCancelled = false;
  6. unsigned long nMsgAmount = 1;
  7.  
  8. QString szTemp = "";
  9. unsigned int iCanId = 0;
  10.  
  11. QString strCanId = "";
  12. QString strData = "";
  13.  
  14. QMutex mutex;
  15.  
  16. while( !m_bCancelled )
  17. {
  18. #ifdef __CANON_
  19. unsigned long numMsgs = 1;
  20. PASSTHRU_MSG *pRxMsg = NULL;
  21. pRxMsg = theApp->GetMessageDetail( &numMsgs, 0 );
  22. nMsgAmount = numMsgs; // store amount of messages we got
  23.  
  24. strData = "";
  25.  
  26. int index = 0;
  27. // Read can data, store in buffer ( read say N amount and then emit? )
  28. while ( numMsgs && !m_bCancelled )
  29. {
  30. mutex.lock();
  31. szTemp = "";
  32. m_can[index].strData = "";
  33. iCanId = 0;
  34. for ( int iLoop = 0; iLoop < 4; iLoop++)
  35. {
  36. iCanId = (iCanId << 8 ) | pRxMsg->Data[iLoop];
  37. }
  38.  
  39. QString strId;
  40. strId.sprintf( "%d", iCanId );
  41. strCanId = strId;
  42.  
  43.  
  44. QString strName = theApp->m_dcb.GetMessageName( strId );
  45. if( strName != "" )
  46. m_can[index].strId = strName;
  47. else
  48. {
  49. if( pRxMsg->RxStatus & 0x100 )
  50. {
  51. m_can[index].strId.sprintf( "%X X", iCanId);
  52. strCanId.sprintf( "%X X", iCanId );
  53. }
  54. else
  55. {
  56. m_can[index].strId.sprintf( "%03X", iCanId);
  57. strCanId.sprintf( "%03X", iCanId );
  58. }
  59. }
  60.  
  61. for ( int iLoop = 4; (unsigned)iLoop < (pRxMsg->DataSize ); iLoop++)
  62. {
  63. szTemp.sprintf("%02X ", pRxMsg->Data[iLoop]);
  64. m_can[index].strData += szTemp;
  65. strData += szTemp;
  66. }
  67.  
  68. m_can[index].strTime.sprintf("%04d", pRxMsg->Timestamp);
  69.  
  70. numMsgs--;
  71.  
  72. m_nCount++;
  73.  
  74. mutex.unlock();
  75.  
  76. } // end while ( ulNoMsgs )
  77.  
  78.  
  79. #else // some dummy data for testing
  80. QString strId = theApp->m_dcb.GetMessageName( "1911" );
  81. if( strId != "" )
  82. m_can[0].strId = strId;
  83. else
  84. m_can[0].strId = "0xfea";
  85.  
  86. m_can[0].strData = "222222222222";
  87. m_can[0].strTime = "----";
  88.  
  89. m_nCount += nMsgAmount;
  90.  
  91. strCanId = "1911";
  92. strData = "2222222222";
  93. #endif
  94. // send out signal
  95. if( nMsgAmount > 0 )
  96. emit scrolltable( m_nCount - 2, nMsgAmount );
  97. msleep(10);
  98.  
  99. } // end while ( true )
  100.  
  101. }
To copy to clipboard, switch view to plain text mode 

Kind regards,
Steve