Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    QDebug() Thread Safe ?

    General and Desktop
    4
    4
    4532
    Loading More Posts
    • 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.
    • L
      LarsG last edited by

      While debugging a deadlock problem I came to wonder if qDebug is thread safe, can it really be true it isn't ?

      The documentation does not explicit mention if it is thread safe or not.

      J 1 Reply Last reply Reply Quote 0
      • M
        miroslav last edited by

        Rule of thumb: If the documentation does not state that something is thread safe, it is not. But I wonder how qDebug() can be involved in a deadlock problem, since it should be reentrant.

        Mirko Boehm | mirko@kde.org | KDE e.V.
        FSFE Fellow
        Qt Certified Specialist

        1 Reply Last reply Reply Quote 1
        • J
          James Mark Chan @LarsG last edited by

          I know this is old but as of 2021/Qt 5 the documentation indicates it is thread safe:
          https://doc.qt.io/qt-5/qtglobal.html#qDebug

          JKSH 1 Reply Last reply Reply Quote 0
          • JKSH
            JKSH Moderators @James Mark Chan last edited by JKSH

            @James-Mark-Chan said in QDebug() Thread Safe ?:

            I know this is old but as of 2021/Qt 5 the documentation indicates it is thread safe:
            https://doc.qt.io/qt-5/qtglobal.html#qDebug

            qDebug() is thread-safe. That means your program won't get corrupted or crash if you use qDebug() in multiple threads.

            However, qDebug() sends data to stderr which is unbuffered. That means if stderr receives data from multiple threads, it might display the data in a way that looks jumbled.

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            1 Reply Last reply Reply Quote 4
            • First post
              Last post