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

Settings don't work with content:// URL on Android

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 6.2.5, 6.4.0 Beta1, 6.5.0 Beta1
    • 6.3.0
    • Core: I/O
    • None
    • Qt 6.3, armeabi-v7a, Pixel 3a
    • Android
    • 140ca89a3c (qt/qtbase/dev) 140ca89a3c (qt/tqtc-qtbase/dev) c140edb442 (qt/qtbase/6.3) c140edb442 (qt/tqtc-qtbase/6.3) e9eae9e0e3 (qt/tqtc-qtbase/6.2) 16414f6d35 (qt/qtbase/6.4) 16414f6d35 (qt/tqtc-qtbase/6.4)
    • 2022wk20FOAndroid&Automotive, 2022wk22FOQtforAndroid

    Description

      I'm trying to write data per QSettings on Android using an URL from a file dialog. The file is created but no content written. Seems the content:// conversion is not working properly, I see multiple files being created in the file dialog of my program after pressing Save (attachment) but only one in the file explorer app.

      Not sure if this warning helps:

      W ParcelFileDescriptor: Peer expected signal when closed; unable to deliver after detach

      Some simplified code:

      import QtQuick
      import QtQuick.Controls
      import QtQuick.Dialogs
      import Qt.labs.platform
      import Qt.labs.settings
      
      Window {
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")
      
          FileDialog {
              id: fileDialog
              folder: StandardPaths.writableLocation(StandardPaths.DocumentsLocation)
              onAccepted: {
                  mySettings.fileName = file
                  mySettings.setValue("test",true)
              }
          }
      
          Settings {
              id: mySettings
          }
      
          Button {
              id: btnClose
              text: "Click me"
              onClicked: {
                  fileDialog.acceptLabel = qsTr("Save")
                  fileDialog.fileMode = FileDialog.SaveFile
                  fileDialog.title = qsTr("Save configuration")
                  fileDialog.open()
              }
          }
      
      }
      

      The actual code runs on Qt with 

          QSettings settings(fileName, QSettings::IniFormat);
          qDebug() << settings.fileName() << settings.status();
      //returns some content:// url and NoError
          settings.beginGroup("config");
          for (auto i = configData.begin(); i!=configData.end(); i++)
              settings.setValue(i.key(), i.value());
          settings.endGroup();
          qDebug() << settings.status(); 
      //still NoError

      Attachments

        Issue Links

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

          Activity

            People

              samuelmira Samuel Mira
              htietze Heiko Tietze
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes