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

Unclear relation between QTemporaryFile::{autoRemove,rename}()

XMLWordPrintable

    • 2
    • fde2ec282 (dev), 8924fdf1b (6.10), 4cf9da126 (6.9), 7de757749 (tqtc/lts-6.8)

      The documentation of QTemporaryFile neglects to define the relation between the autoRemove property and the rename() function, specifically whether a rename() will cause autoRemove to be unset or not.

      Given that rename() is akin to QSaveFile::commit(), in that it "finishes" the write by (atomically) overwriting the old file with the new temp file, one could be mistakenly assume that a rename() would cancel autoRemove. It looks as though one has to explicitly disable it, though.

      The relation between the two should be more explicitly documented, perhaps including a QSaveFile-like example:

      • open QTemporaryFile tmp(target), return if failed
      • write to tmp, return if failed
      • tmp.rename(target), return if failed
      • tmp.setAutoRemove(false);

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

            thiago Thiago Macieira
            mmutz Marc Mutz
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: