From 04bc4330329834bf299c65aa557e7aa8d80ccac2 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Thu, 9 Feb 2023 13:59:16 +0100 Subject: [PATCH] fix: break after determining file access level --- permissions.mm | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/permissions.mm b/permissions.mm index 9583e34..d42c56f 100644 --- a/permissions.mm +++ b/permissions.mm @@ -279,8 +279,8 @@ bool HasOpenSystemPreferencesDialog() { for (NSString *file in files) { const std::string can_read = CheckFileAccessLevel(file); if (can_read == kAuthorized) { - break; auth_status = kAuthorized; + break; } else if (can_read == kDenied) { auth_status = kDenied; } @@ -294,11 +294,7 @@ bool HasOpenSystemPreferencesDialog() { std::string ScreenAuthStatus() { std::string auth_status = kNotDetermined; if (@available(macOS 10.16, *)) { - if (CGPreflightScreenCaptureAccess()) { - auth_status = kAuthorized; - } else { - auth_status = kDenied; - } + auth_status = CGPreflightScreenCaptureAccess() ? kAuthorized : kDenied; } else if (@available(macOS 10.15, *)) { auth_status = kDenied; NSRunningApplication *runningApplication =