diff --git a/checkin_notes b/checkin_notes index de8893454a..a8ec674ba3 100755 --- a/checkin_notes +++ b/checkin_notes @@ -7056,3 +7056,27 @@ David 30 June 2006 lib/ crypt_prog.C filesys.C + +David 30 June 2006 + - core client: ACTIVE_TASK::supports_graphics(): + return false if process isn't executing. + (prevent GUI from showing "show graphics" button + for results with no process, or suspended process) + - core client: on Windows command-line, when you close the window, + quit_client() gets called, + but control never returns to boinc_main_loop(), + so gstate.quit_activities() (and other cleanup stuff) isn't called, + so apps don't exit. + If you then start the core client again in the next 30 sec, + and exit quickly, another copy of apps gets started, + which waits to acquire slot lock, then decides it's in + standalone mode and opens a graphics window! Very confusing. + + I fixed this by moving all the cleanup code to a separate functions + (finalize()) and calling this directly from quit_client(). + + By the way, why is main.C such a toxic waste dump? + + client/ + app_graphics.C + main.C diff --git a/client/app_graphics.C b/client/app_graphics.C index 79f8806868..72847f5ae9 100644 --- a/client/app_graphics.C +++ b/client/app_graphics.C @@ -235,7 +235,9 @@ bool ACTIVE_TASK::supports_graphics() { if (powerpc_emulated_on_i386) return false; #endif - return (graphics_mode_acked != MODE_UNSUPPORTED); + if (graphics_mode_acked == MODE_UNSUPPORTED) return false; + if (task_state != PROCESS_EXECUTING) return false; + return true; } // Return the next graphics-capable running app. diff --git a/client/main.C b/client/main.C index a94469dca3..7e1ddc9976 100644 --- a/client/main.C +++ b/client/main.C @@ -74,6 +74,8 @@ typedef void (CALLBACK* ClientLibraryShutdown)(); #include "main.h" +int finalize(); + static bool boinc_cleanup_completed = false; // Used on Windows 95/98/ME to determine when it is safe to leave // the WM_ENDSESSION message handler and allow Windows to finish @@ -127,6 +129,7 @@ void show_message(PROJECT *p, char* msg, int priority) { #ifdef WIN32 void quit_client() { gstate.requested_exit = true; + finalize(); } void suspend_client() { @@ -394,12 +397,12 @@ static void init_core_client(int argc, char** argv) { #endif } -int boinc_main_loop() { - int retval; #ifdef _WIN32 char event_message[2048]; #endif +int initialize() { + int retval; #ifdef _WIN32 g_hClientLibraryDll = LoadLibrary("boinc.dll"); @@ -417,7 +420,6 @@ int boinc_main_loop() { } #endif - retval = check_unique_instance(); if (retval) { fprintf(stderr, @@ -454,12 +456,9 @@ int boinc_main_loop() { } #endif - curl_init(); - #ifdef _WIN32 - if(g_hClientLibraryDll) { ClientLibraryStartup fnClientLibraryStartup; fnClientLibraryStartup = (ClientLibraryStartup)GetProcAddress(g_hClientLibraryDll, _T("ClientLibraryStartup")); @@ -479,8 +478,15 @@ int boinc_main_loop() { } } } - #endif + return 0; +} + +int boinc_main_loop() { + int retval; + + retval = initialize(); + if (retval) return retval; retval = gstate.init(); if (retval) { @@ -494,7 +500,6 @@ int boinc_main_loop() { return retval; } - #ifdef _WIN32 if (gstate.executing_as_daemon) { LogEventInfoMessage( @@ -503,7 +508,6 @@ int boinc_main_loop() { } #endif - // must parse env vars after gstate.init(); // otherwise items will get overwritten with state file info // @@ -538,8 +542,14 @@ int boinc_main_loop() { DosSleep(0); #endif } - gstate.quit_activities(); + return finalize(); +} +int finalize() { + static bool finalized = false; + if (finalized) return 0; + finalized = true; + gstate.quit_activities(); #ifdef _WIN32 if(g_hClientLibraryDll) { @@ -585,9 +595,7 @@ int boinc_main_loop() { #endif curl_cleanup(); - boinc_cleanup_completed = true; - return 0; }