diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2022-02-01 12:23:51 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-02-01 19:45:28 +0000 |
commit | fd11f3384393d8aa6b1efa1b0dc54e0f356f9686 (patch) | |
tree | 089debf057897c3e07d5f6b994a1a4d2dbb9f3e2 /src/testlib | |
parent | 20ae80e33d3ee09ce5871f49fc7454ea1220c7d8 (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
}
Change-Id: I4ac812014f9ff97bc446806eaf2108cd1c8b89c3
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit 7d19efa7bb837f45812b13b24891bb718e874012)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/testlib')
-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 df403f1d4d..e3ab0accf6 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() |