diff --git a/clientgui/BOINCGUIApp.cpp b/clientgui/BOINCGUIApp.cpp index 151f93398f..31dc7a617f 100644 --- a/clientgui/BOINCGUIApp.cpp +++ b/clientgui/BOINCGUIApp.cpp @@ -412,6 +412,8 @@ bool CBOINCGUIApp::OnInit() { wxSystemOptions::SetOption(wxT("msw.staticbox.optimized-paint"), 0); #endif #ifdef __WXMAC__ + bool launchedFromLogin = false; + // In wxMac-2.8.7, default wxListCtrl::RefreshItem() does not work // so use traditional generic implementation. // This has been fixed in wxMac-2.8.8, but the Mac native implementation: @@ -645,6 +647,36 @@ bool CBOINCGUIApp::OnInit() { } #endif +#ifdef __WXMAC__ + ProcessSerialNumber psn; + ProcessInfoRec pInfo; + OSStatus err; + + memset(&pInfo, 0, sizeof(pInfo)); + pInfo.processInfoLength = sizeof( ProcessInfoRec ); + err = GetProcessInformation(&m_psnCurrentProcess, &pInfo); + if (!err) { + psn = pInfo.processLauncher; + memset(&pInfo, 0, sizeof(pInfo)); + pInfo.processInfoLength = sizeof( ProcessInfoRec ); + err = GetProcessInformation(&psn, &pInfo); + } + // Don't open main window if we were started automatically at login + if (pInfo.processSignature == 'lgnw') { // Login Window app + launchedFromLogin = true; + + // Prevent a situation where wxSingleInstanceChecker lock file + // from last login auto start (with same pid) was not deleted. + // This path must match that in DetectDuplicateInstance() + wxString lockFilePath = wxString(wxFileName::GetHomeDir() + + "/Library/Application Support/BOINC/" + + wxTheApp->GetAppName() + + '-' + wxGetUserId() + ); + boinc_delete_file(lockFilePath.utf8_str()); + } +#endif + // Detect if BOINC Manager is already running, if so, bring it into the // foreground and then exit. if (DetectDuplicateInstance()) { @@ -693,21 +725,7 @@ bool CBOINCGUIApp::OnInit() { IdleTrackerAttach(); #ifdef __WXMAC__ - ProcessSerialNumber psn; - ProcessInfoRec pInfo; - OSStatus err; - - memset(&pInfo, 0, sizeof(pInfo)); - pInfo.processInfoLength = sizeof( ProcessInfoRec ); - err = GetProcessInformation(&m_psnCurrentProcess, &pInfo); - if (!err) { - psn = pInfo.processLauncher; - memset(&pInfo, 0, sizeof(pInfo)); - pInfo.processInfoLength = sizeof( ProcessInfoRec ); - err = GetProcessInformation(&psn, &pInfo); - } - // Don't open main window if we were started automatically at login - if (pInfo.processSignature == 'lgnw') { // Login Window app + if (launchedFromLogin) { m_bGUIVisible = false; // If the system was just started, we usually get a "Connection diff --git a/mac_installer/PostInstall.cpp b/mac_installer/PostInstall.cpp index 35b6fa1a77..1518ec928d 100644 --- a/mac_installer/PostInstall.cpp +++ b/mac_installer/PostInstall.cpp @@ -1530,6 +1530,18 @@ OSErr UpdateAllVisibleUsers(long brandID) } } } + + // Delete the BOINC Manager's wxSingleInstanceChecker lock file, in case + // it was not deleted (such as due to a crash.) + // Lock file name always has "BOINC Manager" even if the application is + // branded, due to SetAppName(wxT("BOINC Manager")) in CBOINCGUIApp::OnInit(). + // This path must match that in CBOINCGUIApp::DetectDuplicateInstance() + sprintf(cmd, "sudo -u \"%s\" rm -f \"/Users/%s/Library/Application Support/BOINC/BOINC Manager-%s\"", + pw->pw_name, pw->pw_name, pw->pw_name); + err = system(cmd); + printf("[2] %s returned %d\n", cmd, err); + fflush(stdout); + } // End for (userIndex=0; userIndex< human_user_names.size(); ++userIndex) ResynchSystem();