From e359383d3bebd583b894c9ee9d02cce2be318b56 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Wed, 26 Jul 2017 20:15:05 -0400 Subject: [PATCH] Mac: Don't execve in main or fork & crash to evade its ill effects... This at once reverts fixes for bugs 543 and 290; 290 being a problem loading libraries, 543 being a minor problem with the fix for 290, resulting in a rewrite of the fix, but this rewrite having bad consequences, as in bugs 1567 and 1703. See discussion in bug 1702 for the detailed history See also commits a05d039055909d7d1dc2d4f31e1fe0659a3207dd (fork and crash) 36361a6b86dac4b0f2b16b7017007b4cc7717c7a (introduced execve) --- src/AudacityApp.cpp | 50 +-------------------------------------------- src/AudacityApp.h | 5 ----- src/MenusMac.cpp | 6 ------ 3 files changed, 1 insertion(+), 60 deletions(-) diff --git a/src/AudacityApp.cpp b/src/AudacityApp.cpp index 1517ab56a..802537476 100644 --- a/src/AudacityApp.cpp +++ b/src/AudacityApp.cpp @@ -651,54 +651,12 @@ public: }; #if defined(__WXMAC__) -// This should be removed when Lame and FFmpeg support is converted -// from loadable libraries to commands. -// -// The purpose of this is to give the user more control over where libraries -// such as Lame and FFmpeg get loaded from. -// -// Since absolute pathnames are used when loading these libraries, the normal search -// path would be DYLD_LIBRARY_PATH, absolute path, DYLD_FALLBACK_LIBRARY_PATH. This -// means that DYLD_LIBRARY_PATH can override what the user actually wants. -// -// So, we simply clear DYLD_LIBRARY_PATH to allow the users choice to be the first -// one tried. + IMPLEMENT_APP_NO_MAIN(AudacityApp) IMPLEMENT_WX_THEME_SUPPORT int main(int argc, char *argv[]) { - bool doCrash = false; - -#ifdef FIX_BUG1567 - doCrash = AudacityApp::IsSierraOrLater(); -#endif - - bool doExec = !doCrash && getenv("DYLD_LIBRARY_PATH"); - unsetenv("DYLD_LIBRARY_PATH"); - - extern char **environ; - -#ifdef FIX_BUG1567 - const char *var_name = "_NO_CRASH"; - if ( doCrash && !( getenv( var_name ) ) ) { - setenv(var_name, "1", TRUE); - // Bizarre fix for Bug1567 - // Crashing one Audacity and immediately starting another avoids intermittent - // failures to load libraries on Sierra - if ( fork() ) - // The original process crashes at once - raise(SIGTERM); - - // Child process can't proceed until doing this: - execve(argv[0], argv, environ); - } - else -#else - if (doExec) - execve(argv[0], argv, environ); -#endif - wxDISABLE_DEBUG_SUPPORT(); return wxEntry(argc, argv); @@ -1542,12 +1500,6 @@ bool AudacityApp::OnInit() temporarywindow.SetTitle(_("Audacity is starting up...")); SetTopWindow(&temporarywindow); -#ifdef FIX_BUG1567 - // Without this, splash screen may be hidden under other programs. - if (IsSierraOrLater()) - MacActivateApp(); -#endif - // ANSWER-ME: Why is YieldFor needed at all? //wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI|wxEVT_CATEGORY_USER_INPUT|wxEVT_CATEGORY_UNKNOWN); wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI); diff --git a/src/AudacityApp.h b/src/AudacityApp.h index edf1961f7..dafca471b 100644 --- a/src/AudacityApp.h +++ b/src/AudacityApp.h @@ -164,12 +164,7 @@ class AudacityApp final : public wxApp { #ifdef __WXMAC__ - #if ! defined(__WXDEBUG__) - #define FIX_BUG1567 - #endif - void MacActivateApp(); - static bool IsSierraOrLater(); #endif diff --git a/src/MenusMac.cpp b/src/MenusMac.cpp index a1b091eca..3b74e0fe4 100644 --- a/src/MenusMac.cpp +++ b/src/MenusMac.cpp @@ -92,9 +92,3 @@ void AudacityApp::MacActivateApp() if ( [app respondsToSelector:@selector(activateIgnoringOtherApps:)] ) [app activateIgnoringOtherApps:YES]; } - -bool AudacityApp::IsSierraOrLater() -{ - auto number = kCFCoreFoundationVersionNumber; - return number >= 1348.1; -}