QDomDocument's setContent(QFile) failing with boost::interprocess timed_lock
-
Hi Guys,
I have this code extracted from a QThread's run() :
@
...
if (input->exists())
{
if (input->open(QFile::ReadOnly | QFile::Text))
{
try
{
file_lock timeLock(m_FileName.c_str()) ;
ptime pt = ptime(second_clock::local_time()) ;
if (timeLock.timed_lock(pt += seconds(5)))
{
if (m_Model->setContent(input))
{
qDebug() << "Content Set" ;
}
else
{
qDebug() << "Unable set content" ;
}
timeLock.unlock() ;
}
else
{
qDebug() << "Unable to get lock!" ;
}
}
catch (lock_exception& e)
{
qDebug() << "Locking" << e.what() << m_FileName.c_str() ;
}
catch (interprocess_exception& e)
{
qDebug() << "Reading" << e.what() << m_FileName.c_str() ;
}
input->close() ;
}
}
@
If you comment out the lines 10 and 20 it works on every execution of the thread. However, when the timed_lock is applied m_Model is unable to set the document's content, with the appropriate message being displayed in the Application Output console.Would anyone know why this is?
Is there away to find out why the content cannot be set? -
Well it appears that this is not what it seems! The issue lies with the timed locking of the file for output! I'll look into it a bit more to see if I've made a screaming error and post back with an update.
Thanks for reading.