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

QmltcCodeWriter::write does not do error checking

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P1: Critical
    • 6.8.0 Beta1
    • 6.8
    • QML: Compiler
    • None
    • 50b9979f89c6bdb761762e8c42176acb6bd7f18c

    Description

      qtdeclarative/tools/qmltc/qmltccodewriter.cpp:221

      static void writeToFile(const QString &path, const QByteArray &data)
      {
          // When not using dependency files, changing a single qml invalidates all
          // qml files and would force the recompilation of everything. To avoid that,
          // we check if the data is equal to the existing file, if yes, don't touch
          // it so the build system will not recompile unnecessary things.
          //
          // If the build system use dependency file, we should anyway touch the file
          // so qmltc is not re-run
          QFileInfo fi(path);
          if (fi.exists() && fi.size() == data.size()) {
              QFile oldFile(path);
              oldFile.open(QIODevice::ReadOnly);
              if (oldFile.readAll() == data)
                  return;
          }
          QFile file(path);
          file.open(QIODevice::WriteOnly);
          file.write(data);
      }
       

      There's no error checking done here for filesystem errors. Is a qFatal() appropriate, or should the code be refactored to handle the error cleanly?

      Attachments

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

        Activity

          People

            peppe Giuseppe D'Angelo
            peppe Giuseppe D'Angelo
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes