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. An opinion on a console application where there are both QTimer and QThread.

An opinion on a console application where there are both QTimer and QThread.

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 1.0k 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.
  • mrdebugM Offline
    mrdebugM Offline
    mrdebug
    wrote on last edited by
    #1

    I have an application where there are the QThread and QTimer objects. The objects can meet the same bottleneck when they have to write the log files.
    When the the QThread object has to append something to the log files it emits an event. The QTimer appends someting to the log file when the OnTimer event is emitted.
    Is this scenario wrong and unstable? Sometimes the application goes to crash and after many days on searching I haven't got any idea on where the bug could be.

    Need programmers to hire?
    www.labcsp.com
    www.denisgottardello.it
    GMT+1
    Skype: mrdebug

    E 1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      There may be a race condition of both writing to log file at same time. That may cause mess up in log file. However i'm sure this may not lead to crash. Are you using any synchronisation mechanism to avoid the race condition between two threads writing to a file ? May be a good idea to try if not tried.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      1
      • mrdebugM Offline
        mrdebugM Offline
        mrdebug
        wrote on last edited by
        #3

        In the log function I'm using a QMutex.

        Need programmers to hire?
        www.labcsp.com
        www.denisgottardello.it
        GMT+1
        Skype: mrdebug

        1 Reply Last reply
        0
        • mrdebugM mrdebug

          I have an application where there are the QThread and QTimer objects. The objects can meet the same bottleneck when they have to write the log files.
          When the the QThread object has to append something to the log files it emits an event. The QTimer appends someting to the log file when the OnTimer event is emitted.
          Is this scenario wrong and unstable? Sometimes the application goes to crash and after many days on searching I haven't got any idea on where the bug could be.

          E Offline
          E Offline
          Eeli K
          wrote on last edited by
          #4

          @mrdebug Which thread does the logging? You have a QThread object - does it logging or does the main thread it? Are signals connected between threads or inside one thread? Some kind of architectural explanation or diagram would be useful.

          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