From 7d19efa7bb837f45812b13b24891bb718e874012 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 1 Feb 2022 12:23:51 +0100 Subject: testlib: Disable window restoration on macOS in a non-persistent way MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The recommended way to register defaults on macOS is via registerDefaults: which puts the key/value into the volatile NSRegistrationDomain. This stops testlib from dumping preference files into ~/Library/Preferences: ❯ plutil -p tst_qwidget.plist { "ApplePersistenceIgnoreState" => 1 } Pick-to: 6.2 6.3 5.15 Change-Id: I4ac812014f9ff97bc446806eaf2108cd1c8b89c3 Reviewed-by: Timur Pocheptsov --- src/testlib/qtestutil_macos.mm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/testlib/qtestutil_macos.mm') diff --git a/src/testlib/qtestutil_macos.mm b/src/testlib/qtestutil_macos.mm index 880cd0f91f..e6638e5cb8 100644 --- a/src/testlib/qtestutil_macos.mm +++ b/src/testlib/qtestutil_macos.mm @@ -53,8 +53,11 @@ namespace QTestPrivate { to start with a clean slate and prevents the "previous restore failed" dialog from showing if there was a test crash. */ - void disableWindowRestore() { - [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"ApplePersistenceIgnoreState"]; + void disableWindowRestore() + { + [NSUserDefaults.standardUserDefaults registerDefaults:@{ + @"ApplePersistenceIgnoreState" : @YES + }]; } bool macCrashReporterWillShowDialog() -- cgit v1.2.3