Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTemporaryFile: file not being created in Qt 5.11/5.12
Forum Updated to NodeBB v4.3 + New Features

QTemporaryFile: file not being created in Qt 5.11/5.12

Scheduled Pinned Locked Moved Unsolved General and Desktop
22 Posts 7 Posters 2.6k Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Christian EhrlicherC Online
    Christian EhrlicherC Online
    Christian Ehrlicher
    Lifetime Qt Champion
    wrote on last edited by
    #4

    I don't see it as bug here - a temporary file may not exist on the disk at all so exists() may return false. As soon as you call fileName() you force Qt to create a file on disk and it exists there.

    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
    Visit the Qt Academy at https://academy.qt.io/catalog

    K 1 Reply Last reply
    1
    • Christian EhrlicherC Christian Ehrlicher

      I don't see it as bug here - a temporary file may not exist on the disk at all so exists() may return false. As soon as you call fileName() you force Qt to create a file on disk and it exists there.

      K Offline
      K Offline
      koahnig
      wrote on last edited by
      #5

      @Christian-Ehrlicher

      That is disputable.

      According to the documentation of bool QTemporaryFile::open(QIODevice::OpenMode flags) it says:
      Creates a unique file name for the temporary file, and opens it. You can get the unique name later by calling fileName(). The file is guaranteed to have been created by this function (i.e., it has never existed before).

      For the open used in the code bool QTemporaryFile::open() it states only:
      A QTemporaryFile will always be opened in QIODevice::ReadWrite mode, this allows easy access to the data in the file. This function will return true upon success and will set the fileName() to the unique filename used.

      Also there seems to be a change in functionality between versions according to the first post.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      1
      • Christian EhrlicherC Online
        Christian EhrlicherC Online
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #6

        @koahnig said in QTemporaryFile: file not being created in Qt 5.11:

        That is disputable.

        Then please discuss this on the LKML, O_TMPFILE, when supported, doesn't create visible directory entry. As soon as you want it to be visible (= calling fileName()) this changes. See also e.g. here: http://man7.org/linux/man-pages/man2/open.2.html

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        sierdzioS 1 Reply Last reply
        1
        • Christian EhrlicherC Christian Ehrlicher

          @koahnig said in QTemporaryFile: file not being created in Qt 5.11:

          That is disputable.

          Then please discuss this on the LKML, O_TMPFILE, when supported, doesn't create visible directory entry. As soon as you want it to be visible (= calling fileName()) this changes. See also e.g. here: http://man7.org/linux/man-pages/man2/open.2.html

          sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #7

          @Christian-Ehrlicher said in QTemporaryFile: file not being created in Qt 5.11:

          @koahnig said in QTemporaryFile: file not being created in Qt 5.11:

          That is disputable.

          Then please discuss this on the LKML, O_TMPFILE, when supported, doesn't create visible directory entry. As soon as you want it to be visible (= calling fileName()) this changes. See also e.g. here: http://man7.org/linux/man-pages/man2/open.2.html

          That's fine and I agree with that.

          But, if it worked one way in Qt 5.9 and works in a different way in 5.11, then it's a regression - so definitely a bug and also a high priority one.

          (Z(:^

          AritzA 1 Reply Last reply
          0
          • sierdzioS sierdzio

            @Christian-Ehrlicher said in QTemporaryFile: file not being created in Qt 5.11:

            @koahnig said in QTemporaryFile: file not being created in Qt 5.11:

            That is disputable.

            Then please discuss this on the LKML, O_TMPFILE, when supported, doesn't create visible directory entry. As soon as you want it to be visible (= calling fileName()) this changes. See also e.g. here: http://man7.org/linux/man-pages/man2/open.2.html

            That's fine and I agree with that.

            But, if it worked one way in Qt 5.9 and works in a different way in 5.11, then it's a regression - so definitely a bug and also a high priority one.

            AritzA Offline
            AritzA Offline
            Aritz
            wrote on last edited by
            #8

            @sierdzio They closed my bug report as invalid. This is affecting Qt 5.12.6 also, BTW.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #9

              Hi,

              Can you post the link to the bug report ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              AritzA 1 Reply Last reply
              0
              • SGaistS SGaist

                Hi,

                Can you post the link to the bug report ?

                AritzA Offline
                AritzA Offline
                Aritz
                wrote on last edited by
                #10

                @SGaist https://bugreports.qt.io/browse/QTBUG-80157

                1 Reply Last reply
                0
                • JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by JonB
                  #11

                  I have read both sides of this: the bug report + Qt documentation, and the Linux open docs for O_TMPFILE. I can see both sides of the argument, and of course understand that Qt wants to use the OS facility.

                  I admit I have not tried it, but how does, say, Qt docs stating stuff like

                  The file name of the temporary file can be found by calling fileName().
                  A temporary file will have some static part of the name and some part that is calculated to be unique.
                  and will be placed into the temporary path as returned by QDir::tempPath().

                  marry with the O_TMPFILE docs of

                  Create an unnamed temporary regular file
                  (2) can never be reached via any pathname
                  (4) do not require the caller to devise unique names

                  I am also intrigued that apparently the implementation has changed from Qt 5.9 to 5.11, I wonder why now.

                  It's easy for me to say, but some hints in the Qt docs about this possible behaviour might be welcome. I fully understand that it is not Qt's job to document everything which might be going on under each platform, but there are other precedents in the docs which do give the user a clue about platform-specific behaviour, or what to expect/not expect....

                  1 Reply Last reply
                  0
                  • Christian EhrlicherC Online
                    Christian EhrlicherC Online
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on last edited by
                    #12

                    The support for O_TMPFILE was added in 5.10 and there was even a big changelog entry for this: https://code.qt.io/cgit/qt/qtbase.git/tree/dist/changes-5.10.0/?h=v5.10.0

                    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                    Visit the Qt Academy at https://academy.qt.io/catalog

                    sierdzioS 1 Reply Last reply
                    5
                    • Christian EhrlicherC Christian Ehrlicher

                      The support for O_TMPFILE was added in 5.10 and there was even a big changelog entry for this: https://code.qt.io/cgit/qt/qtbase.git/tree/dist/changes-5.10.0/?h=v5.10.0

                      sierdzioS Offline
                      sierdzioS Offline
                      sierdzio
                      Moderators
                      wrote on last edited by
                      #13

                      @Christian-Ehrlicher said in QTemporaryFile: file not being created in Qt 5.11/5.12:

                      The support for O_TMPFILE was added in 5.10 and there was even a big changelog entry for this: https://code.qt.io/cgit/qt/qtbase.git/tree/dist/changes-5.10.0/?h=v5.10.0

                      Great, thanks for the link.

                      I'd still say there should be a note about this in Qt docs for Qt >5.10. Many other such OS "curiosities" are mentioned in the docs.

                      (Z(:^

                      1 Reply Last reply
                      0
                      • Christian EhrlicherC Online
                        Christian EhrlicherC Online
                        Christian Ehrlicher
                        Lifetime Qt Champion
                        wrote on last edited by
                        #14

                        @sierdzio said in QTemporaryFile: file not being created in Qt 5.11/5.12:

                        I'd still say there should be a note about this in Qt docs

                        Feel free to provide a patch ;)

                        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                        Visit the Qt Academy at https://academy.qt.io/catalog

                        sierdzioS 1 Reply Last reply
                        1
                        • Christian EhrlicherC Christian Ehrlicher

                          @sierdzio said in QTemporaryFile: file not being created in Qt 5.11/5.12:

                          I'd still say there should be a note about this in Qt docs

                          Feel free to provide a patch ;)

                          sierdzioS Offline
                          sierdzioS Offline
                          sierdzio
                          Moderators
                          wrote on last edited by
                          #15

                          @Christian-Ehrlicher said in QTemporaryFile: file not being created in Qt 5.11/5.12:

                          @sierdzio said in QTemporaryFile: file not being created in Qt 5.11/5.12:

                          I'd still say there should be a note about this in Qt docs

                          Feel free to provide a patch ;)

                          Oh I wish, but no time right now.

                          I'll bookmark this, though and hopefully come back with a patch some day.

                          (Z(:^

                          aha_1980A 1 Reply Last reply
                          0
                          • sierdzioS sierdzio

                            @Christian-Ehrlicher said in QTemporaryFile: file not being created in Qt 5.11/5.12:

                            @sierdzio said in QTemporaryFile: file not being created in Qt 5.11/5.12:

                            I'd still say there should be a note about this in Qt docs

                            Feel free to provide a patch ;)

                            Oh I wish, but no time right now.

                            I'll bookmark this, though and hopefully come back with a patch some day.

                            aha_1980A Offline
                            aha_1980A Offline
                            aha_1980
                            Lifetime Qt Champion
                            wrote on last edited by
                            #16

                            @sierdzio

                            I'll bookmark this, though and hopefully come back with a patch some day.

                            Too late :) But you can review the patch: https://codereview.qt-project.org/c/qt/qtbase/+/282081

                            Qt has to stay free or it will die.

                            JonBJ 1 Reply Last reply
                            2
                            • sierdzioS Offline
                              sierdzioS Offline
                              sierdzio
                              Moderators
                              wrote on last edited by
                              #17

                              Great, thanks! Looks good. I may be lacking some powers as I don't see any +1 button I can click.

                              (Z(:^

                              1 Reply Last reply
                              0
                              • SGaistS Offline
                                SGaistS Offline
                                SGaist
                                Lifetime Qt Champion
                                wrote on last edited by
                                #18

                                It's in the dialog you get when you hit the Reply button.

                                Interested in AI ? www.idiap.ch
                                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                1 Reply Last reply
                                1
                                • sierdzioS Offline
                                  sierdzioS Offline
                                  sierdzio
                                  Moderators
                                  wrote on last edited by
                                  #19

                                  Ah OK found it under REPLY. That gerrit UI...

                                  (Z(:^

                                  1 Reply Last reply
                                  1
                                  • aha_1980A aha_1980

                                    @sierdzio

                                    I'll bookmark this, though and hopefully come back with a patch some day.

                                    Too late :) But you can review the patch: https://codereview.qt-project.org/c/qt/qtbase/+/282081

                                    JonBJ Offline
                                    JonBJ Offline
                                    JonB
                                    wrote on last edited by
                                    #20

                                    @aha_1980
                                    Whoever made that doc change (you? some bot?!), it's perfect!

                                    aha_1980A 1 Reply Last reply
                                    1
                                    • JonBJ JonB

                                      @aha_1980
                                      Whoever made that doc change (you? some bot?!), it's perfect!

                                      aha_1980A Offline
                                      aha_1980A Offline
                                      aha_1980
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #21

                                      @JonB It was me. I copied the text from the 5.10 changelog :)

                                      Qt has to stay free or it will die.

                                      1 Reply Last reply
                                      2
                                      • K Offline
                                        K Offline
                                        koahnig
                                        wrote on last edited by
                                        #22

                                        Thanks to all being involved in the discussion.
                                        When answering with 1st and 2nd post I did not expect to create so much fuzz around this issue. With the mass of comments and different references. Therefore, I miss a crucial point here.

                                        I am happy with the functionality, since there are good reasons as I expect with the summarized expertize being involved in the discussion. After a couple of trials I was also able to review @aha_1980 's addition to the documentation, which clarifies things generally.
                                        I guess there is still a different behaviour of exist() after the 2 versions of open to be callable. Since the second says that the file is definitely created, it has to be the first open() as used by @Aritz
                                        Personally I would add a short reference to the detailed information section on linux for the first open() version. Something like:
                                        See note on Linux above

                                        If my assumption is wrong and the issue with exists() is for both open versions the same, we have a different ambiguity in the documentation respectively a bug in the description for bool QTemporaryFile::open(QIODevice::OpenMode flags) . In this case a reference or modification in documentation is required for second open version.

                                        Vote the answer(s) that helped you to solve your issue(s)

                                        1 Reply Last reply
                                        0

                                        • Login

                                        • Login or register to search.
                                        • First post
                                          Last post
                                        0
                                        • Categories
                                        • Recent
                                        • Tags
                                        • Popular
                                        • Users
                                        • Groups
                                        • Search
                                        • Get Qt Extensions
                                        • Unsolved