Bug2437: possible further help...

... The 100ms sleep added at at a675b5907f 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.
This commit is contained in:
Paul Licameli 2020-12-09 15:18:49 -05:00
parent ab15efebf5
commit 64b066f655
3 changed files with 11 additions and 1 deletions

View File

@ -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);
});

View File

@ -92,6 +92,7 @@ class AudacityApp final : public wxApp {
#ifdef __WXMAC__
void MacActivateApp();
void MacFinishLaunching();
#endif

View File

@ -4,7 +4,7 @@
#include <AppKit/NSApplication.h>
// 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