diff --git a/clientgui/MainDocument.cpp b/clientgui/MainDocument.cpp index 9d125abc60..13ead4dc48 100644 --- a/clientgui/MainDocument.cpp +++ b/clientgui/MainDocument.cpp @@ -29,6 +29,7 @@ #include "BOINCGUIApp.h" #include "BOINCBaseFrame.h" #include "MainDocument.h" +#include #ifdef SANDBOX #include @@ -397,6 +398,16 @@ int CMainDocument::OnPoll() { m_pNetworkConnection->Poll(); } + // Every 10 seconds, kill any running graphics apps + // whose associated worker tasks are no longer running + wxDateTime timeNow = wxDateTime::Now(); + wxTimeSpan ts(timeNow - m_dtKillInactiveGfxTimestamp); + if (ts.GetSeconds() > 10) { + CachedResultsStatusUpdate(); + m_dtKillInactiveGfxTimestamp = timeNow; + KillInactiveGraphicsApps(); + } + return iRetVal; } @@ -981,8 +992,8 @@ int CMainDocument::WorkResume(std::string& strProjectURL, std::string& strName) } -// If the graphics application for the current task is already running, -// return a pointer to its RUNNING_GFX_APP struct. +// If the graphics application for the current task is already +// running, return a pointer to its RUNNING_GFX_APP struct. RUNNING_GFX_APP* CMainDocument::GetRunningGraphicsApp(RESULT* result, int slot) { bool exited = false; @@ -1026,6 +1037,7 @@ RUNNING_GFX_APP* CMainDocument::GetRunningGraphicsApp(RESULT* result, int slot) } +// Kill any running graphics apps whose worker tasks aren't running void CMainDocument::KillInactiveGraphicsApps() { std::vector::iterator gfx_app_iter; diff --git a/clientgui/MainDocument.h b/clientgui/MainDocument.h index 0f7f64aca4..6b77b34f44 100644 --- a/clientgui/MainDocument.h +++ b/clientgui/MainDocument.h @@ -186,6 +186,7 @@ public: private: int CachedResultsStatusUpdate(); wxDateTime m_dtResultsTimestamp; + wxDateTime m_dtKillInactiveGfxTimestamp; std::vector m_running_gfx_apps; RUNNING_GFX_APP* GetRunningGraphicsApp(RESULT* result, int slot); void KillAllRunningGraphicsApps();