diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2022-02-01 12:23:51 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2022-02-01 16:56:02 +0100 |
commit | 7d19efa7bb837f45812b13b24891bb718e874012 (patch) | |
tree | 938e6022ba89b23f90215531021c45651a2ff86f /src/testlib/qtestutil_macos.mm | |
parent | 24301726390eb97f9bd00ab5cb40b70d70e119fc (diff) |
testlib: Disable window restoration on macOS in a non-persistent way
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 <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/testlib/qtestutil_macos.mm')
-rw-r--r-- | src/testlib/qtestutil_macos.mm | 7 |
1 files changed, 5 insertions, 2 deletions
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() |