From 7bf5c79a710026b510b2b552a6efc8b174804be8 Mon Sep 17 00:00:00 2001 From: Ryan Ferrell Date: Mon, 23 Aug 2021 15:16:32 -0700 Subject: [PATCH] =?UTF-8?q?CGWindowListScreenCapturer=20=E2=80=94=20=20#23?= =?UTF-8?q?=20Move=20unhideOnNextDisplay=20to=20a=20single=20queue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Metal/ScreenCapture/CGWindowListScreenCapturer.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Metal/ScreenCapture/CGWindowListScreenCapturer.swift b/Metal/ScreenCapture/CGWindowListScreenCapturer.swift index df99652..2866117 100644 --- a/Metal/ScreenCapture/CGWindowListScreenCapturer.swift +++ b/Metal/ScreenCapture/CGWindowListScreenCapturer.swift @@ -134,10 +134,8 @@ private extension CGWindowListScreenCapturer { func afterCapturingUnhideOnNextDisplayIfNeeded() { guard unhideOnNextDisplay else { return } + unhideOnNextDisplay = false DispatchQueue.main.async { [weak self] in - // recheck, because the state could have changed since the dispatch - guard self?.unhideOnNextDisplay == true else { return } - self?.unhideOnNextDisplay = false self?.view?.isHidden = false } } @@ -254,7 +252,9 @@ private extension CGWindowListScreenCapturer { if let link = displayLink { CVDisplayLinkStart(link) } capturingDisabled = false captureImmediately() - unhideOnNextDisplay = true + queue?.async { [weak self] in + self?.unhideOnNextDisplay = true + } } } }