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

Qt5.12.1 - Linux/gcc_64 - "QTemporaryFile->open()" needs the help of a workaround...

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 5.12.1
    • Core: Other
    • None
    • Ubuntu 16.04.5 LTS 64-Bit" / ".../Qt5.12.1/5.12.1/gcc_64/
    • Linux/X11

    Description

      From the documentation: "QTemporaryFile is used to create unique temporary files safely. The file itself is created by calling open()."

      Being on "Ubuntu 16.04.5 LTS 64-Bit" with ".../Qt5.12.1/5.12.1/gcc_64/" "QTemporaryFile->open()" does not open the file ==> "QTemporaryFile->exists() == false".
      Placing "(void) QTemporaryFile->fileName()" right under "QTemporaryFile->open()", triggers the opening of the file ==> "QTemporaryFile->exists() == true".

      Identical source code without the workaround: "(void) QTemporaryFile->fileName()" works nicely on e.g. Windows7 and the latest OSX.

      The last Qt version without the above behavior is Qt5.12.0.

      Btw...: Same behavior in case the "QTemporaryFile" is not a pointer...

      Extracted source code:

      class webGate: public QNetworkAccessManager

      { Q_OBJECT public: webGate(QObject * parent = 0); ~webGate(); // ... private: QTemporaryFile *currentQTemporaryFile; }

      ;

      webGate::webGate(QObject * parent) :
      QNetworkAccessManager(parent)

      { // ... currentQTemporaryFile = new QTemporaryFile(this); // ... }

      void webGate::resultExtraction() {
      // ...
      if (currentQTemporaryFile->exists())

      { // ... }

      else {
      if (currentQTemporaryFile->open()) {
      #ifdef _linux_
      if (!currentQTemporaryFile->exists())

      { (void) currentQTemporaryFile->fileName(); // Currently necessary workaround on Linux/Qt5.12.1 ... }

      else

      { qDebug().noquote().nospace() << __FILE__ << ":" << QString::number(__LINE__) << "\tOPENED \"QTemporaryFile\" WITHOUT \"EXISTENCE CHECK WORKAROUND\" ON LINUX...!\n"; }

      #endif
      #if defined(_APPLE_) || defined(_WIN32)
      if (!currentQTemporaryFile->exists())

      { (void) currentQTemporaryFile->fileName(); // Not necessary on Windows/OSX/Qt5.12.1 ... qDebug().noquote().nospace() << __FILE__ << ":" << QString::number(__LINE__) << "\tHAD TO USE \"EXISTENCE CHECK WORKAROUND\" TO OPEN \"QTemporaryFile\" ON WINDOWS OR ON OSX...!\n"; }

      #endif
      } else

      { qDebug().noquote().nospace() << __FILE__ << ":" << QString::number(__LINE__) << "\tCOULD NOT OPEN \"QTemporaryFile\"...!\n"; }

      // ...
      }
      // ...
      }

      Attachments

        Issue Links

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

          Activity

            People

              thiago Thiago Macieira
              michaelPTech Michael Hartung
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes