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. qInstallMessageHandler not showing anything when in debug mode
QtWS25 Last Chance

qInstallMessageHandler not showing anything when in debug mode

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 742 Views
  • 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.
  • Q Offline
    Q Offline
    QtTester
    wrote on last edited by QtTester
    #1

    Hi,all:
    platform: win10+5.14.1+vs2017. qtcreator 4.11/ 6.0.2
    with helper, qInstallMessageHandler runs fine when you run the app, but if you press F5 enter debug mode, it shows nothing. I have to uncomment :

    //qInstallMessageHandler()
    

    so it can show debug string again. why?
    good shown:
    微信截图_20220519095917.png

    bad shown in DEBUG MODE:
    微信截图_20220519095934.png

    1 Reply Last reply
    0
    • hskoglundH Offline
      hskoglundH Offline
      hskoglund
      wrote on last edited by
      #4

      Hi, I also use qInstallMessageHandler and I remember also having problems with debug output: inside Qt there is a check for recursive calls to a custom message handler (in case there's a qDebug() call inside your message handler for example) so I ended up calling the Win32 OutputDebugString() directly in my message handler, like this:

          ::OutputDebugStringA(qUtf8Printable(msg + "\n"));
      

      In Linux and on the Mac fprintf() and fflush() work fine, it's just Windows that needs this workaround. Maybe it can solve your problem too...

      Q 1 Reply Last reply
      2
      • Q Offline
        Q Offline
        QtTester
        wrote on last edited by QtTester
        #2

        I also try GDB, if adding fflush(stderr), it outputs perfectly. but delay output if not adding fflush():
        Maybe this is a qc bug when using CDB ???

        微信截图_20220519100958.png

        微信截图_20220519101305.png

        Q 1 Reply Last reply
        0
        • Q QtTester

          I also try GDB, if adding fflush(stderr), it outputs perfectly. but delay output if not adding fflush():
          Maybe this is a qc bug when using CDB ???

          微信截图_20220519100958.png

          微信截图_20220519101305.png

          Q Offline
          Q Offline
          QtTester
          wrote on last edited by
          #3

          Anyone has this problem?

          1 Reply Last reply
          0
          • hskoglundH Offline
            hskoglundH Offline
            hskoglund
            wrote on last edited by
            #4

            Hi, I also use qInstallMessageHandler and I remember also having problems with debug output: inside Qt there is a check for recursive calls to a custom message handler (in case there's a qDebug() call inside your message handler for example) so I ended up calling the Win32 OutputDebugString() directly in my message handler, like this:

                ::OutputDebugStringA(qUtf8Printable(msg + "\n"));
            

            In Linux and on the Mac fprintf() and fflush() work fine, it's just Windows that needs this workaround. Maybe it can solve your problem too...

            Q 1 Reply Last reply
            2
            • hskoglundH hskoglund

              Hi, I also use qInstallMessageHandler and I remember also having problems with debug output: inside Qt there is a check for recursive calls to a custom message handler (in case there's a qDebug() call inside your message handler for example) so I ended up calling the Win32 OutputDebugString() directly in my message handler, like this:

                  ::OutputDebugStringA(qUtf8Printable(msg + "\n"));
              

              In Linux and on the Mac fprintf() and fflush() work fine, it's just Windows that needs this workaround. Maybe it can solve your problem too...

              Q Offline
              Q Offline
              QtTester
              wrote on last edited by
              #5

              @hskoglund Works for me, thank you. I confirm it is a qtctreator's BUG.

              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