From 72d15ba3b685acd4c3a3e8e5a66e7bccca1bdd70 Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Tue, 28 Feb 2017 05:16:42 -0800 Subject: [PATCH] SCR: Mac: replace all deprecated Mac APIs as of OS 10.9 --- clientscr/Mac_Saver_Module.h | 2 +- clientscr/mac_saver_module.cpp | 23 +++++++---------------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/clientscr/Mac_Saver_Module.h b/clientscr/Mac_Saver_Module.h index 3ebd9ea39c..6334c62f22 100644 --- a/clientscr/Mac_Saver_Module.h +++ b/clientscr/Mac_Saver_Module.h @@ -123,7 +123,7 @@ protected: int launch_screensaver(RESULT* rp, int& graphics_application); int launch_default_screensaver(char *dir_path, int& graphics_application); void HandleRPCError(void); - OSErr KillScreenSaver(void); + int KillScreenSaver(void); void GetDefaultDisplayPeriods(struct ss_periods &periods); bool HasProcessExited(pid_t pid, int &exitCode); pthread_t m_hDataManagementThread; diff --git a/clientscr/mac_saver_module.cpp b/clientscr/mac_saver_module.cpp index 963e2de1ed..ff6dba97fd 100644 --- a/clientscr/mac_saver_module.cpp +++ b/clientscr/mac_saver_module.cpp @@ -264,8 +264,6 @@ CScreensaver::CScreensaver() { int CScreensaver::Create() { - ProcessSerialNumber psn; - ProcessInfoRec pInfo; OSStatus err; // Ugly workaround for a problem with the System Preferences app @@ -280,12 +278,8 @@ int CScreensaver::Create() { // fails to run and stderr shows the message: // "The process has forked and you cannot use this CoreFoundation // functionality safely. You MUST exec()" - GetCurrentProcess(&psn); - memset(&pInfo, 0, sizeof(pInfo)); - pInfo.processInfoLength = sizeof( ProcessInfoRec ); - pInfo.processName = NULL; - err = GetProcessInformation(&psn, &pInfo); - if ( (err == noErr) && (pInfo.processSignature == 'sprf') ) { + pid_t SystemPrefsPID = getPidIfRunning("com.apple.systempreferences"); + if (SystemPrefsPID == getpid()) { saverState = SaverState_ControlPanelTestMode; } @@ -883,16 +877,13 @@ pid_t CScreensaver::FindProcessPID(char* name, pid_t thePID) // Send a Quit AppleEvent to the process which called this module // (i.e., tell the ScreenSaver engine to quit) -OSErr CScreensaver::KillScreenSaver() { - ProcessSerialNumber thisPSN; +int CScreensaver::KillScreenSaver() { pid_t thisPID; - OSErr err = noErr; + int retval; - GetCurrentProcess(&thisPSN); - err = GetProcessPID(&thisPSN , &thisPID); - if (err == noErr) - err = kill(thisPID, SIGABRT); // SIGINT - return err; + thisPID = getpid(); + retval = kill(thisPID, SIGABRT); // SIGINT + return retval; }