Results 1 to 2 of 2

Thread: QSqlQuery queue notification when finished

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2009
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QSqlQuery queue notification when finished

    Hi,
    I'm building a server application that has multiple sources of input and needs to run queries in the background. I have following design:
    DataSession: QObject - this class adds queries into QQueue and wakes QueryCommiter class, which is derived from QThread and runs queries.
    Next class is EfsSqlQuery, derived from QObject, containing 1 QSqlQuery object, and one method, exec(), which runs the query and emits signal commited().

    The question is, I want to catch the signal in my server application like this:
    Qt Code:
    1. connect(m_query.data(), SIGNAL(commited(bool)), this, SLOT(process_stage_2(bool)));
    To copy to clipboard, switch view to plain text mode 
    and then call
    Qt Code:
    1. dataSession.commitQuery(m_query);
    To copy to clipboard, switch view to plain text mode 
    which, as I described above, adds query to the queue and notifies the QueryCommiter class, that calls exec method of QSqlQuery and emits the signal.

    The slot(process_stage_2(bool)) is never executed, though. But the SIGNAL IS emitted in the EfsSqlQuery!

    I'll try to attach some relevant code:
    Server code:
    Qt Code:
    1. connect(m_query.data(), SIGNAL(commited(bool)), this, SLOT(process_stage_2(bool)));
    2.  
    3. dataSession.commitQuery(m_query);
    To copy to clipboard, switch view to plain text mode 

    DataSession code:
    Qt Code:
    1. void sk_efs_server::DataSession::commitQuery(QSharedPointer<EfsSqlQuery> query)
    2. {
    3. sqlMutex->lock();
    4. sqlQueue->append(query);
    5. sqlMutex->unlock();
    6.  
    7. sqlQueueFull->wakeAll();
    8. }
    To copy to clipboard, switch view to plain text mode 

    QueryCommiter code:
    Qt Code:
    1. void sk_efs_server::QueryCommiter::run()
    2. {
    3. QSharedPointer<EfsSqlQuery> query;
    4.  
    5. forever
    6. {
    7. sqlMutex->lock();
    8. sqlQueueFull->wait(sqlMutex.data());
    9. query = sqlQueue->dequeue();
    10. sqlMutex->unlock();
    11.  
    12. query->exec();
    13. }
    14.  
    15. exec();
    16. }
    To copy to clipboard, switch view to plain text mode 

    EfsSqlQuery code:
    Qt Code:
    1. bool sk_efs_server::EfsSqlQuery::exec()
    2. {
    3. bool cted = m_query->exec();
    4.  
    5. emit commited(cted);
    6.  
    7. return cted;
    8. }
    To copy to clipboard, switch view to plain text mode 

    Why is the signal never caught in my server thread even though it is emmited by EfsSqlQuery?

    Thanks in advance.

  2. #2
    Join Date
    Jan 2009
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSqlQuery queue notification when finished

    Connecting the SIGNAL as Qt::QueuedConnection doesn't help. Is there any way to debug SIGNALs ?

Similar Threads

  1. Notification in KDE
    By mpele in forum KDE Forum
    Replies: 0
    Last Post: 23rd November 2009, 10:24
  2. help regarding queue
    By aj2903 in forum Qt Programming
    Replies: 1
    Last Post: 3rd April 2009, 07:48
  3. QT taskbar notification
    By bunjee in forum Qt Programming
    Replies: 1
    Last Post: 4th December 2007, 20:41
  4. QQueue vs STL queue
    By Lele in forum Qt Programming
    Replies: 3
    Last Post: 8th November 2007, 17:35
  5. Cannot queue...
    By vratojr in forum Qt Programming
    Replies: 3
    Last Post: 9th May 2006, 15:06

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.