From 8103f74d3eaa90750eca4fae12fbff4ceb791f1e Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Thu, 27 Sep 2007 13:09:48 +0000 Subject: [PATCH] API: fix 2 bugs in new compatibility code for handling V5 graphics messages in a V5 app svn path=/trunk/boinc/; revision=13681 --- api/boinc_api.C | 16 +++++++++++++--- checkin_notes | 12 ++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/api/boinc_api.C b/api/boinc_api.C index 82c4f08575..2db8ec26c6 100644 --- a/api/boinc_api.C +++ b/api/boinc_api.C @@ -154,6 +154,9 @@ struct UPLOAD_FILE_STATUS { static bool have_new_upload_file; static std::vector upload_file_status; +static char graphics_app_path[1024]; +static void control_graphics_app(char* path, bool start, bool fullscreen); + static int setup_shared_mem() { if (standalone) { fprintf(stderr, "Standalone mode, so not using shared memory.\n"); @@ -428,6 +431,11 @@ int boinc_finish(int status) { // This is called from the worker, timer, and graphics threads. // void boinc_exit(int status) { + // kill the (separate) graphics app if running + if (options.backwards_compatible_graphics && graphics_app_path[0]) { + control_graphics_app(graphics_app_path, false, false); + } + // Unlock the lock file // file_lock.unlock(LOCKFILE); @@ -711,9 +719,9 @@ static void handle_process_control_msg() { static void control_graphics_app(char* path, bool start, bool fullscreen) { static bool running = false; #ifdef _WIN32 - HANDLE pid=0; + static HANDLE pid=0; #else - int pid; + static int pid=0; #endif if (start) { int argc; @@ -736,6 +744,7 @@ static void control_graphics_app(char* path, bool start, bool fullscreen) { int retval = run_program(0, abspath, argc, argv, 0, pid); if (retval) { running = false; + pid = 0; } else { running = true; } @@ -743,6 +752,7 @@ static void control_graphics_app(char* path, bool start, bool fullscreen) { if (running) { kill_program(pid); running = false; + pid = 0; } } } @@ -753,7 +763,6 @@ static void control_graphics_app(char* path, bool start, bool fullscreen) { // static inline void handle_graphics_messages() { char buf[MSG_CHANNEL_SIZE]; - static char graphics_app_path[1024]; GRAPHICS_MSG m; static bool first=true; static bool have_graphics_app; @@ -765,6 +774,7 @@ static inline void handle_graphics_messages() { ); if (!strcmp(graphics_app_path, GRAPHICS_APP_FILENAME)) { have_graphics_app = false; + graphics_app_path[0] = 0; } else { have_graphics_app = true; } diff --git a/checkin_notes b/checkin_notes index d316c380fa..34affbd43d 100755 --- a/checkin_notes +++ b/checkin_notes @@ -8833,3 +8833,15 @@ David 26 Sept 2007 lib/ shmem.h util.C + +Charlie 27 Sep 2007 + - API: fix 2 bugs in new compatibility code for handling V5 graphics + messages in a V5 app. + - Make graphics app's pid static so it is still available when + time to "hide" graphics. + - Kill graphics app when worker app exits; this is needed to work + properly with V5 screensaver. + + api/ + boinc_api.C + \ No newline at end of file