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. Recommendation for QSaveFile commit()

Recommendation for QSaveFile commit()

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 677 Views
  • 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.
  • R Offline
    R Offline
    rhb327
    wrote on last edited by
    #1

    Is it still required to run system("sync") after a QSaveFile's commit() call? I'm thinking it is safer to do so but would like to double check.

    Thanks,
    -Rich

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

      @rhb327 said in Recommendation for QSaveFile commit():

      Is it still required to run system("sync") after a QSaveFile's commit() call?

      Why should it? Where in the documentation did you read such a strange recommendation?

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

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rhb327
        wrote on last edited by
        #3

        No, I didn't see it recommended anywhere. By "required", I mean should I run system("sync") after a call to commit() to ensure an embedded file in eMMC or on a USB is truly updated or does commit() guarantee the same file status as system("sync")?

        One reason I ask, in my testing, I occasionally see a file like: xxxx.csv.BHYUIS vs. xxxx.csv on an export to USB. I have not determined root cause for this but on inspection of the file contents it looks like the full data is in the csv is truly there but the final move by QSaveFile did not appear to occur. In this specific case I'm not replacing a file but generating one.

        Thanks,
        -Rich

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

          This is a OS problem, nothing Qt can do against it. Qt is calling fsync() or fdatasync() when you call QSaveFile::flush() - what the OS does with this is out of Qt's scope.

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

          1 Reply Last reply
          2
          • R Offline
            R Offline
            rhb327
            wrote on last edited by
            #5

            Ok, so shouldn't be required is my takeaway from this discussion.

            I'll probably leave the system("sync") for now just to be conservative.

            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