- MGR: Check for a duplicate instance much earlier in the initialization

cycle, before any window or document creation.  Prevents rapid window
        creation and then destruction.
        
    clientgui/
        BOINCGUIApp.cpp, .h

svn path=/trunk/boinc/; revision=22504
This commit is contained in:
Rom Walton 2010-10-14 18:16:24 +00:00
parent db5832a189
commit f204e817f6
3 changed files with 33 additions and 0 deletions

View File

@ -7317,3 +7317,11 @@ Charlie 14 Oct 2010
client/
cs_scheduler.cpp
Rom 14 Oct 2010
- MGR: Check for a duplicate instance much earlier in the initialization
cycle, before any window or document creation. Prevents rapid window
creation and then destruction.
clientgui/
BOINCGUIApp.cpp, .h

View File

@ -381,6 +381,13 @@ bool CBOINCGUIApp::OnInit() {
}
#endif
// Detect if BOINC Manager is already running, if so, bring it into the
// foreground and then exit.
if (!m_bMultipleInstancesOK) {
if (DetectDuplicateInstance()) {
return false;
}
}
// Initialize the main document
m_pDocument = new CMainDocument();
@ -652,6 +659,23 @@ void CBOINCGUIApp::DetectAccessibilityEnabled() {
}
///
/// Detect if another instance of this application is running.
// Returns true if there is, otherwise false
///
bool CBOINCGUIApp::DetectDuplicateInstance() {
#ifdef __WXMSW__
HWND hWnd = ::FindWindow(NULL, m_pSkinManager->GetAdvanced()->GetApplicationName().c_str());
if (hWnd) {
::ShowWindow(hWnd, SW_SHOW);
::SetForegroundWindow(hWnd);
return true;
}
#endif
return false;
}
///
/// Determines what name BOINC Manager is called.
///

View File

@ -60,6 +60,7 @@ protected:
void DetectDisplayInfo();
void DetectAccessibilityEnabled();
bool DetectDuplicateInstance();
void DetectExecutableName();
void DetectRootDirectory();
void DetectDataDirectory();