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

Suggestion: Qt6 Mqtt "qmqttclient.cpp" code improving

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.5.2
    • MQTT
    • None
    • All

    Description

      In "qmqttclient.cpp":

      QMqttClientPrivate::QMqttClientPrivate(QMqttClient *c)
          : QObjectPrivate()
      {
          m_client = c;
          m_clientId = QUuid::createUuid().toString();
          m_clientId.remove(QLatin1Char('{'));
          m_clientId.remove(QLatin1Char('}'));
          m_clientId.remove(QLatin1Char('-'));
          m_clientId.resize(23);
      #ifdef QT_BUILD_INTERNAL
          // Some test servers require a username token
          if (qEnvironmentVariableIsSet("QT_MQTT_TEST_USERNAME"))
              m_username = qEnvironmentVariable("QT_MQTT_TEST_USERNAME");
          if (qEnvironmentVariableIsSet("QT_MQTT_TEST_PASSWORD"))
              m_password = qEnvironmentVariable("QT_MQTT_TEST_PASSWORD");
          if (qEnvironmentVariableIsSet("QT_MQTT_TEST_CLIENTID"))
              m_clientId = qEnvironmentVariable("QT_MQTT_TEST_CLIENTID");
      #endif
      }
      
      m_clientId = QUuid::createUuid().toString();
      m_clientId.remove(QLatin1Char('{'));
      m_clientId.remove(QLatin1Char('}'));
      m_clientId.remove(QLatin1Char('-'));
      

      I think these 4 lines can be replaced by one:

      m_clientId = QUuid::createUuid().toString(QUuid::Id128);
      

      The same codes otherwhere can be improved like above.

      Attachments

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

        Activity

          People

            mkalinow Maurice Kalinowski
            roachlin Lin Lin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes