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

QSettings cannot parse IniFormat file properly

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 5.14.0
    • Core: I/O
    • None
    • Tested under Arch linux with Qt 5.14 and also tested with 5.11.3 from debian buster.
    • All

    Description

      Test code:

          QSettings test("/home/username/tmp/aaa.ini", QSettings::IniFormat);
          qDebug() << test.allKeys();
      

      Expect:

      qDebug print all five keys in aaa.ini

      Actual Result:

      qDebug print: ("KeyOne", "KeyThree", "KeyTwo")

      ---------------------------

      I got this issue when I use QSettings parse .desktop file with something like:

      QSettings settings("/path/to/file.desktop", QSettings::IniFormat)
      

      While I know .desktop file is not the very same thing as .ini format file, but using QSettings to get all keys should works. Then I found it cannot find the key of a .desktop file from GNOME Evolution properly (org.gnome.Evolution.desktop). I did a quick debug and found once it read at the line of 'Comment[he]' key, it will read the entire following data as the value of that key probably because it cannot find the LF('\n') character.

      Since it's still not an INI format file, I modified that file and make the file as simple as possible and hopefully I didn't get it wrong, and the attachment is the files which can be used for testing. The `aaa.orig.desktop` is a copy of the original `org.gnome.Evolution.desktop` file which I get from Debian buster Evolution package, `aaa.desktop` is just the same file but removed a few lines above the 'Comment[he]' key, and the `aaa.ini` is my approach to make it as a valid INI format file(by convert LF to CR LF, and rename the section name and key name).

      Here is the content of the INI file:

      [General]
      KeyOne=Xestione o seu correo, contactos e programación
      KeyTwo=તમારું ઈમેઈલ, સંપર્કો અને સમયક્રમની વ્યવસ્થા કરો
      KeyThree=נהל את הדוא"ל, אנשי הקשר ולוח הזמנים שלך
      KeyFour=अपना ईमेल संपर्क व योजना प्रबंधित करें
      KeyFive=Upravljanje poštom, kontaktima i rasporedom
      

      For the given .ini file (and also the `aaa.desktop`), if we use QSettings with QSettings::IniFormat to parse the file and use QSettings::allKeys() to get the keys, we can see we only get the first three keys, it's "KeyOne", "KeyThree", "KeyTwo" for the ini file and it's "Desktop Entry/Comment[gl]", "Desktop Entry/Comment[gu]", "Desktop Entry/Comment[he]" for the aaa.desktop file.

      I'm not sure if it's an issue of QSettings or it's not a valid INI format file. Sorry if I did something wrong.

      Attachments

        1. aaa.desktop
          13 kB
          Gary Wang
        2. aaa.ini
          0.4 kB
          Gary Wang
        3. aaa.orig.desktop
          34 kB
          Gary Wang
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            blumia Gary Wang
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes