Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-107659

QMessageLogger provides no way to suppress a warning from QT_FATAL_WARNINGS's count

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.4
    • None
    • All

    Description

      QTest registers its own message logger, overriding the default one. The replacement supports suppressing some warnings, that are expected (e.g. when a test is deliberately provoking the warning to verify that relevant abuse of an API does lead to it) and indeed the test fails if they're not there. However, qlogging.cpp's isFatal()'s count-down based on QT_FATAL_WARNINGS (and I guess the same is true for QT_FATAL_CRITICALS) will still happen, as QMessageLogger::warning() only delegates to the replacement message logger for the actual production of messages; it gets no hint back from that process to say that the message was suppressed, so has no way to bypass the isFatal() check it always does after emitting the message.

      The result is that QTest::ignoreMessage() only suppresses output and verifies the message is produced; it is unable to actually cause QMessageLogger to ignore the message (as its name claims).
      Fixing this will require some changes internal to QMessageLogger plus a change to the return-type of the QtMessageHandler function type.
      Hopefully we can add a new overload to qInstallMessageHandler() that takes a function returning something other than the current void, while making the present signature wrap its void-returning parameter in a lambda that forwards the arguments and returns a default "carry on" value of the new type, rather than whatever return value we introduce to mean "forget this message".
      Then internally we'd just use the new signature and let the return from the message handler tell us whether to continue to the isFatal() check.

      If and when we've done that, we can move on to enabling QTest's replacement logger to make use of it.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              cnn Qt Core & Network
              Eddy Edward Welbourne
              Vladimir Minenko Vladimir Minenko
              Alex Blasche Alex Blasche
              Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes