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

Qt 5.7.0 QSettings fails to save QVariantHash on macOS Sierra

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3: Somewhat important
    • 5.15
    • 5.7.0
    • Core: I/O
    • None
    • $ sw_vers
      ProductName: Mac OS X
      ProductVersion: 10.12
      BuildVersion: 16A323
    • macOS

    Description

      #include <QSettings>
      #include <QVariant>
      #include <QHash>
      #include <QDebug>
      
      int main()
      {
          QSettings pref("foo", "bar");
          QVariantHash hash;
          hash["one"] = 1;
          hash["three"] = "tres";
          hash["seven"] = 7;
          pref.setValue("baz", hash);
      
          hash = pref.value("baz").toHash();
          QVariantHash::const_iterator it = hash.begin();
          QVariantHash::const_iterator end = hash.end();
          for(; it != end; ++it) {
              qDebug() << it.key() << it.value();
          }
      
          return 0;
      }
      

      Above code prints nothing. The created .plist file is broken.

      $ plutil -convert xml1 ~/Library/Preferences/com.foo.bar.plist 
      $ cat ~/Library/Preferences/com.foo.bar.plist 
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
      <plist version="1.0">
      <dict>
      	<key>baz</key>
      	<string>@Variant(</string>
      </dict>
      </plist>
      

      Attachments

        1. com.foo.bar.plist
          0.2 kB
          Yez Ezey
        2. varhash.cpp
          0.5 kB
          Yez Ezey
        3. varhash.pro
          0.3 kB
          Yez Ezey
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            vestbo Tor Arne Vestbø
            debugger Yez Ezey
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes