mirror of https://github.com/BOINC/boinc.git
- 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:
parent
db5832a189
commit
f204e817f6
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
///
|
||||
|
|
|
@ -60,6 +60,7 @@ protected:
|
|||
|
||||
void DetectDisplayInfo();
|
||||
void DetectAccessibilityEnabled();
|
||||
bool DetectDuplicateInstance();
|
||||
void DetectExecutableName();
|
||||
void DetectRootDirectory();
|
||||
void DetectDataDirectory();
|
||||
|
|
Loading…
Reference in New Issue