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

QLoggingCategory::installFilter crashes with the code from documentation

    XMLWordPrintable

Details

    • 6ae2bfad41 (qt/qtbase/dev) 6ae2bfad41 (qt/tqtc-qtbase/dev) 28390ce4aa (qt/qtbase/6.4) 28390ce4aa (qt/tqtc-qtbase/6.4) 49de278cd2 (qt/qtbase/6.3) 49de278cd2 (qt/tqtc-qtbase/6.3) 062423a7a1 (qt/tqtc-qtbase/5.15) c5c7daf67a (qt/tqtc-qtbase/6.2)

    Description

      +underlined text+In the documentation example I see the usage of previous filter. I think, it is meant to use in the following way:

      oldCategoryFilter = QLoggingCategory::installFilter(myCategoryFilter);
      

      This code leads to crash, as QLoggingCategory::installFilter() call myCategoryFilter() when oldCategoriFilter is not valid yet.
      The workaround is to use this code:

      oldCategoryFilter = QLoggingCategory::installFilter(Q_NULLPTR);
      QLoggingCategory::installFilter(myCategoryFilter);
      

      This is not obvious and looks like a hack, so I think it is either a bug, or should be pointed in documentation.

      Attachments

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

        Activity

          People

            Eddy Edward Welbourne
            krnekit Nikita Krupenko
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: