From 64b066f6556d4a51f34440035bfbec886de90c98 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Wed, 9 Dec 2020 15:18:49 -0500 Subject: [PATCH] Bug2437: possible further help... ... The 100ms sleep added at at a675b5907f5fa7bba2537c249a84f73cabe5937c was meant to let NS framework events arrive on another thread and be detected by wxWidgets. But there are still reports that it is not reliable enough. This other fix may be sufficient alone, making the sleep unnecessary. But it is harmless so we will leave it there. --- src/AudacityApp.cpp | 4 ++++ src/AudacityApp.h | 1 + src/AudacityApp.mm | 7 ++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/AudacityApp.cpp b/src/AudacityApp.cpp index 1b3d3cd61..94f970f4f 100644 --- a/src/AudacityApp.cpp +++ b/src/AudacityApp.cpp @@ -1279,8 +1279,12 @@ bool AudacityApp::OnInit() // See CreateSingleInstanceChecker() where we send those paths over a // socket to the prior instance. using namespace std::chrono; + // This sleep may be unnecessary, but it is harmless. It less NS framework + // events arrive on another thread, but it might not always be long enough. std::this_thread::sleep_for(100ms); CallAfter([this]{ + // This call is what probably makes the sleep unnecessary: + MacFinishLaunching(); if (!InitPart2()) exit(-1); }); diff --git a/src/AudacityApp.h b/src/AudacityApp.h index 5c480194c..de84c5dc6 100644 --- a/src/AudacityApp.h +++ b/src/AudacityApp.h @@ -92,6 +92,7 @@ class AudacityApp final : public wxApp { #ifdef __WXMAC__ void MacActivateApp(); + void MacFinishLaunching(); #endif diff --git a/src/AudacityApp.mm b/src/AudacityApp.mm index 2dbe7e763..7de6987d6 100644 --- a/src/AudacityApp.mm +++ b/src/AudacityApp.mm @@ -4,7 +4,7 @@ #include -// One Mac-only method of class AudacityApp that uses Objective-C is kept +// Mac-only methods of class AudacityApp that use Objective-C are kept // here so that AudacityApp.cpp can be just C++ // The function is not presently used. See commit @@ -20,4 +20,9 @@ void AudacityApp::MacActivateApp() [app activateIgnoringOtherApps:YES]; } +void AudacityApp::MacFinishLaunching() +{ + [NSApp finishLaunching]; +} + #endif