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

[iOS] FileDialog is unable to select files from iCloud Drive

    XMLWordPrintable

Details

    • iOS/tvOS/watchOS

    Description

      When using FileDialog on iOS and selecting a file from user's iCloud Drive, the dialog fails and shows this error: 

      Cannot set /private/var/mobile/Library/Mobile Documents/com~apple~CloudDocs/example.file as a selected file because it doesn't exist 

      This is caused by the fact, that QQuickFileDialog checks the file existence before setting it as selected. This works fine for regular files, but for some reason QFileInfo::exists fails for iCloud Drive files,

      According to Apple's docs, Qt should call `startAccessingSecurityScopedResource` before using QFileInfo::exists and `stopAccessingSecurityScopedResource` right after it.

      I tested it and adding `startAccessingSecurityScopedResource` makes QFileInfo::exists work correctly for iCloud Drive files, and the FileDialog starts working as well

      As a side note, I think Qt should provide some wrappers to `startAccessingSecurityScopedResource` and `stopAccessingSecurityScopedResource` functions, because without them the FileDialog on a recent iOS is not very useful

      Another side note: Is this check really necessary? How is it possible to select a file which doesn't exist? Is there any platform on which that can happen?

      The problematic check is here: https://github.com/qt/qtdeclarative/blob/838b9ee9fe3ad26e5b1fac1616cb575288f4f8a1/src/quickdialogs/quickdialogs/qquickfiledialog.cpp#L167-L168

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-112962
          # Subject Branch Project Status CR V

          Activity

            People

              tpochep Timur Pocheptsov
              mechan Adrian Eddy
              Votes:
              3 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes