tst_QSettings: Don't assume the presence of a key means isWritable

The previous sync() of the specific scope and domain may have failed due
to not having the necessary permissions, but the saved value may still be
cached, so we need to check both.

This was observed on macOS Sierra, where a failed sync() will result in
marking the CFPrefsPlistSource as read-only, eg:

  2016-10-04 13:14:11.713271 tst_qsettings[88537:767733] [User Defaults] attempt to set
  <private> for key in <private> in read-only (due to a previous failed write) preferences
  domain CFPrefsPlistSource<0x6180000e1780> (Domain: org.software.KillerAPP,
  User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null))

Change-Id: I8976c1c4acfe2cb0d5510298d5c585faca9607f6
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
This commit is contained in:
Tor Arne Vestbø 2016-10-04 13:39:30 +02:00
parent f90d6445a0
commit 76f53791a1

View File

@ -3014,7 +3014,7 @@ void tst_QSettings::isWritable()
QSettings s2(format, QSettings::SystemScope, "software.org", "Something Different");
QSettings s3(format, QSettings::SystemScope, "foo.org", "Something Different");
if (s1.contains("foo")) {
if (s1.status() == QSettings::NoError && s1.contains("foo")) {
#if defined(Q_OS_MACX)
QVERIFY(s1.isWritable());
if (format == QSettings::NativeFormat) {