Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QDomDocument's setContent(QFile) failing with boost::interprocess timed_lock
Forum Updated to NodeBB v4.3 + New Features

QDomDocument's setContent(QFile) failing with boost::interprocess timed_lock

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 3.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    WilliamU
    wrote on last edited by
    #1

    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?

    Regards,

    William

    1 Reply Last reply
    0
    • W Offline
      W Offline
      WilliamU
      wrote on last edited by
      #2

      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.

      Regards,

      William

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved