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

QNetworkConfiguration::StateFlag suggests flags although values are not independent

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • Not Evaluated
    • None
    • 5.12.0
    • None
    • All of them

    Description

      QNetworkConfiguration::StateFlag contains various status codes for network configuration.

      The term "flag" suggests that every item's value is a different single bit within the integer value so that individual flags can be or'ed together and the presence of a flag can be checked by and'ing the appropriate flag and check whether the result is zero, e.g.

      if (config_flag & QNetworkConfiguration::Active !=)

      { // Do something when config_flag contained Active }

      However, as the values contain multiple bits, for example Active is 0x000000e which is binary 1110, testing is true against binary 1000, 0100 and 0010.

      Fixing this will break binary compatibility, however, it should be clearly stated in the documentation that the usual behavior of bitflags does not apply here, especially as it is also declared as QFlags which explicitely states the OR-combination of flags.

       

      Attachments

        Activity

          People

            tpochep Timur Pocheptsov
            axeljaeger Axel Jäger
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: