Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-27363

Don't rely on QtcProcess::errorString()

    XMLWordPrintable

Details

    • All

    Description

      Don't rely on QtcProcess::errorString() when choosing possible code paths, as this is just a human readable string. Please see how QIODevice::errorString() is implemented.

      Example misuse:

      void RsyncDeployService::createRemoteDirectories()
      {
      ...
          connect(m_mkdir.get(), &QtcProcess::done, this, [this] {
              QString userError;
              const QString error = m_mkdir->errorString();
              if (!error.isEmpty())
                         ^^^
                  userError = error;
              if (m_mkdir->exitCode() != 0)
                  userError = QString::fromUtf8(m_mkdir->readAllStandardError());
              if (!userError.isEmpty()) {
                  emit errorMessage(tr("Failed to create remote directories: %1").arg(userError));
                  setFinished();
                  return;
              }
              deployFiles();
          });
      ...
      }
      

      Client code should first check if QtcProcess::error() != QProcessError::UnknownError.

      Currently it's being worked around inside QtcProcessPrivate::handleDone() - see HACK comment.

      Attachments

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

        Activity

          People

            jkobus Jarek Kobus
            jkobus Jarek Kobus
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes