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

Qt-6.5 + iOS + QFileDialog::getOpenFileUrl(), unable to read file content

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.4.3, 6.5.2, 6.5.3
    • None
    • developer environment: mac Mini Apple M2, macOS 13.4.1
      deployment device: iPad gen. 5, iPadOS 16.5.1
    • iOS/tvOS/watchOS

    Description

      Hello.

      I'm trying to read the file content of a file which I want to select using the QFileDialog::getOpenFileUrl() method. I'm using Qt-6.5.3. The code is quite simple:

      QUrl url = QFileDialog::getOpenFileUrl(0, caption, dir, filter);
      qDebug() << "Received URL: " << url;
      QFile file(url.toLocalFile());
      QFileInfo fi(url.toLocalFile());
      qDebug() << "File " << url.toLocalFile() << " size: " << file.size() << " exists: " << file.exists();
      qDebug() << "FileInfo " << url.toLocalFile() << " size: " << fi.size() << " exists: " << fi.exists();
      

      When compiled with Qt-6.5.3 the code generates the following output:

      [DocumentManager] revealDocumentAtURL encountered an error: (null)
      warning: stale focus object 0x0 , doing manual update (/Users/qt/work/qt/qtbase/src/plugins/platforms/ios/qiosinputcontext.mm:635, virtual void QIOSInputContext::update(Qt::InputMethodQueries)())
      debug: Received URL:  QUrl("file:///private/var/mobile/Containers/Data/Application/4F4DE0D2-2150-4DFE-902A-48A581B43FE4/Documents/Datovka/Email/9201992/textova-zprava.pdf")
      debug: File  "/private/var/mobile/Containers/Data/Application/4F4DE0D2-2150-4DFE-902A-48A581B43FE4/Documents/Datovka/Email/9201992/textova-zprava.pdf"  size:  0  exists:  false
      debug: FileInfo  "/private/var/mobile/Containers/Data/Application/4F4DE0D2-2150-4DFE-902A-48A581B43FE4/Documents/Datovka/Email/9201992/textova-zprava.pdf"  size:  0  exists:  false
      [DocumentManager] The view service did terminate with error: Error Domain=_UIViewServiceErrorDomain Code=1 "(null)" UserInfo={Terminated=disconnect method}
      

      The URL cannot be read in Qt-6.5.

      But the code seems to work fine with Qt-5.15:

      [DocumentManager] revealDocumentAtURL encountered an error: (null)
      [DocumentManager] Failed to associate thumbnails for picked URL file:///private/var/mobile/Containers/Data/Application/4F4DE0D2-2150-4DFE-902A-48A581B43FE4/Documents/Datovka/Email/9201992/textova-zprava.pdf with the Inbox copy file:///private/var/mobile/Containers/Data/Application/B056D293-E406-4B68-B693-EF8A30DFB320/tmp/cz.nic.mobile-datovka.testing-Inbox/textova-zprava.pdf: Error Domain=QLThumbnailErrorDomain Code=102 "(null)" UserInfo={NSUnderlyingError=0x281389b90 {Error Domain=GSLibraryErrorDomain Code=3 "Generation not found" UserInfo={NSDescription=Generation not found}}}
      warning: stale focus object QObject(0x0) , doing manual update (qiosinputcontext.mm:670, virtual void QIOSInputContext::update(Qt::InputMethodQueries)())
      debug: Received URL:  QUrl("file:///private/var/mobile/Containers/Data/Application/B056D293-E406-4B68-B693-EF8A30DFB320/tmp/cz.nic.mobile-datovka.testing-Inbox/textova-zprava.pdf")
      debug: File  "/private/var/mobile/Containers/Data/Application/B056D293-E406-4B68-B693-EF8A30DFB320/tmp/cz.nic.mobile-datovka.testing-Inbox/textova-zprava.pdf"  size:  4344  exists:  true
      debug: FileInfo  "/private/var/mobile/Containers/Data/Application/B056D293-E406-4B68-B693-EF8A30DFB320/tmp/cz.nic.mobile-datovka.testing-Inbox/textova-zprava.pdf"  size:  4344  exists:  true
      [DocumentManager] The view service did terminate with error: Error Domain=_UIViewServiceErrorDomain Code=1 "(null)" UserInfo={Terminated=disconnect method}
      

      Data from the URL can be read in Qt-5.15.

      The difference between Qt-6.5 and Qt-5.15 seems to be that 5.15 creates a copy and then passes the URL onto the copy

      file:///private/var/mobile/Containers/Data/Application/B056D293-E406-4B68-B693-EF8A30DFB320/tmp/cz.nic.mobile-datovka.testing-Inbox/textova-zprava.pdf

      whereas 6.5 passes the URL to the original file

      file:///private/var/mobile/Containers/Data/Application/4F4DE0D2-2150-4DFE-902A-48A581B43FE4/Documents/Datovka/Email/9201992/textova-zprava.pdf

      .

      Is there a bug in Qt-6?

      Than you very much for the response.

      Attachments

        Issue Links

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

          Activity

            People

              dorisverria Doris Verria
              martinstraka Martin Straka
              Votes:
              4 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes