Debugger [CDB]: Release COM interfaces on RunControl finished.

Ensure that at most one instance of the CDBEngine is alive.
Prevent inconsistent debugger states if several sessions are started.
Squashed cherry-picked commits from master correcting the
plugin state handling (2efdeb5cd0,
57f7616286).

Reviewed-by: hjk
Task-number: QTCREATORBUG-2894
(cherry picked from commit 5a5ba58dc9)
This commit is contained in:
hjk
2010-10-26 17:08:12 +02:00
committed by dt
parent 49cac3d448
commit 6e37beaf53
3 changed files with 77 additions and 15 deletions

View File

@@ -168,6 +168,10 @@ bool CdbEnginePrivate::init(QString *errorMessage)
DebuggerEngine *CdbEngine::create(const DebuggerStartParameters &sp,
QString *errorMessage)
{
if (!CdbCore::CoreEngine::interfacesAvailable()) {
*errorMessage = CdbEngine::tr("An instance of the CDB engine is still running; cannot create an a new instance.");
return 0;
}
CdbEngine *rc = new CdbEngine(sp);
if (rc->m_d->init(errorMessage)) {
rc->syncDebuggerPaths();
@@ -563,6 +567,7 @@ void CdbEngine::processTerminated(unsigned long exitCode)
bool CdbEnginePrivate::endInferior(bool detachOnly, QString *errorMessage)
{
QTC_ASSERT(hasInterfaces(), return true; )
// Prevent repeated invocation.
const bool hasHandles = m_hDebuggeeProcess != NULL;
if (debugCDBExecution)
@@ -635,6 +640,8 @@ void CdbEnginePrivate::endDebugging(bool detachOnly)
if (debugCDBExecution)
qDebug("endDebugging() detach=%d, state=%s", detachOnly, DebuggerEngine::stateName(m_engine->state()));
QTC_ASSERT(hasInterfaces(), return; )
switch (m_engine->state()) {
case DebuggerNotReady:
case EngineShutdownOk:
@@ -659,6 +666,8 @@ void CdbEnginePrivate::endDebugging(bool detachOnly)
m_engine->showMessage(errorMessage, LogError);
m_engine->notifyEngineShutdownFailed();
}
// At this point release interfaces as we might be kept around by the run control.
releaseInterfaces();
}
void CdbEngine::detachDebugger()