Thanks Marcel,
I have put a QMutex in my class and have done the following :
PASSTHRU_MSG* QTCanMonitor::GetMessageDetail( unsigned long *pulNumMsgs, int iChannelIndex )
{
unsigned long ulTimeout = 0;
int iReply = -1;
if( m_pPassThruReadMsgs && m_bConnected )
{
iReply = (m_pPassThruReadMsgs)( m_lChannelID[iChannelIndex], m_CanMsg, pulNumMsgs, ulTimeout );
if( iReply == -1 )
{
return NULL;
}
}
else
return NULL;
return m_CanMsg;
}
PASSTHRU_MSG* QTCanMonitor::GetMessageDetail( unsigned long *pulNumMsgs, int iChannelIndex )
{
QMutexLocker locker(&m_mutex);
unsigned long ulTimeout = 0;
int iReply = -1;
if( m_pPassThruReadMsgs && m_bConnected )
{
iReply = (m_pPassThruReadMsgs)( m_lChannelID[iChannelIndex], m_CanMsg, pulNumMsgs, ulTimeout );
if( iReply == -1 )
{
return NULL;
}
}
else
return NULL;
return m_CanMsg;
}
To copy to clipboard, switch view to plain text mode
Where m_mutex is the QMutex at class scope.
This works a treat. And yes, there is only one instance of the class the above method is in.
Regards,
Steve
Bookmarks