Debugger: Properly exit when engine run failed

Instantly stop the engine if e.g. the port is blocked. If we let
it running until the user closes the dialog, the timeout for automatic
connects would be triggered, and we'd get yet another dialog afterwards
telling the user that the connection failed.

Change-Id: Ifd0e9d743f3b8f4ba853be032d9527559ef6004e
Reviewed-by: Aurindam Jana <aurindam.jana@nokia.com>
This commit is contained in:
Kai Koehne
2012-03-14 15:33:33 +01:00
parent cbc328e2d7
commit ccc55a6149
2 changed files with 26 additions and 17 deletions

View File

@@ -346,7 +346,7 @@ QmlEngine::QmlEngine(const DebuggerStartParameters &startParameters,
connect(&d->m_outputParser, SIGNAL(noOutputMessage()), connect(&d->m_outputParser, SIGNAL(noOutputMessage()),
this, SLOT(beginConnection())); this, SLOT(beginConnection()));
connect(&d->m_outputParser, SIGNAL(errorMessage(QString)), connect(&d->m_outputParser, SIGNAL(errorMessage(QString)),
this, SLOT(connectionStartupFailed(QString))); this, SLOT(appStartupFailed(QString)));
// Only wait 8 seconds for the 'Waiting for connection' on application ouput, then just try to connect // Only wait 8 seconds for the 'Waiting for connection' on application ouput, then just try to connect
// (application output might be redirected / blocked) // (application output might be redirected / blocked)
@@ -434,7 +434,7 @@ void QmlEngine::beginConnection(quint16 port)
} }
} }
void QmlEngine::connectionStartupFailed(const QString &errorMessage) void QmlEngine::connectionStartupFailed()
{ {
if (isSlaveEngine()) { if (isSlaveEngine()) {
if (masterEngine()->state() != InferiorRunOk) { if (masterEngine()->state() != InferiorRunOk) {
@@ -447,19 +447,11 @@ void QmlEngine::connectionStartupFailed(const QString &errorMessage)
QMessageBox *infoBox = new QMessageBox(Core::ICore::mainWindow()); QMessageBox *infoBox = new QMessageBox(Core::ICore::mainWindow());
infoBox->setIcon(QMessageBox::Critical); infoBox->setIcon(QMessageBox::Critical);
infoBox->setWindowTitle(tr("Qt Creator")); infoBox->setWindowTitle(tr("Qt Creator"));
if (qobject_cast<QmlAdapter *>(sender())) { infoBox->setText(tr("Could not connect to the in-process QML debugger."
infoBox->setText(tr("Could not connect to the in-process QML debugger." "\nDo you want to retry?"));
"\nDo you want to retry?")); infoBox->setStandardButtons(QMessageBox::Retry | QMessageBox::Cancel |
infoBox->setStandardButtons(QMessageBox::Retry | QMessageBox::Cancel | QMessageBox::Help);
QMessageBox::Help); infoBox->setDefaultButton(QMessageBox::Retry);
infoBox->setDefaultButton(QMessageBox::Retry);
}
if (qobject_cast<QmlJsDebugClient::QDeclarativeOutputParser *>(sender())) {
infoBox->setText(tr("Could not connect to the in-process QML debugger."
"\n%1").arg(errorMessage));
infoBox->setStandardButtons(QMessageBox::Ok | QMessageBox::Help);
infoBox->setDefaultButton(QMessageBox::Ok);
}
infoBox->setModal(true); infoBox->setModal(true);
connect(infoBox, SIGNAL(finished(int)), connect(infoBox, SIGNAL(finished(int)),
@@ -468,6 +460,22 @@ void QmlEngine::connectionStartupFailed(const QString &errorMessage)
infoBox->show(); infoBox->show();
} }
void QmlEngine::appStartupFailed(const QString &errorMessage)
{
QMessageBox *infoBox = new QMessageBox(Core::ICore::mainWindow());
infoBox->setIcon(QMessageBox::Critical);
infoBox->setWindowTitle(tr("Qt Creator"));
infoBox->setText(tr("Could not connect to the in-process QML debugger."
"\n%1").arg(errorMessage));
infoBox->setStandardButtons(QMessageBox::Ok | QMessageBox::Help);
infoBox->setDefaultButton(QMessageBox::Ok);
connect(infoBox, SIGNAL(finished(int)),
this, SLOT(errorMessageBoxFinished(int)));
infoBox->show();
notifyEngineRunFailed();
}
void QmlEngine::errorMessageBoxFinished(int result) void QmlEngine::errorMessageBoxFinished(int result)
{ {
switch (result) { switch (result) {
@@ -484,7 +492,7 @@ void QmlEngine::errorMessageBoxFinished(int result)
if (state() == InferiorRunOk) { if (state() == InferiorRunOk) {
notifyInferiorSpontaneousStop(); notifyInferiorSpontaneousStop();
notifyInferiorIll(); notifyInferiorIll();
} else { } else if (state() == EngineRunRequested) {
notifyEngineRunFailed(); notifyEngineRunFailed();
} }
break; break;

View File

@@ -163,7 +163,8 @@ signals:
private slots: private slots:
void beginConnection(quint16 port = 0); void beginConnection(quint16 port = 0);
void connectionEstablished(); void connectionEstablished();
void connectionStartupFailed(const QString &errorMessage = QString()); void connectionStartupFailed();
void appStartupFailed(const QString &errorMessage);
void connectionError(QAbstractSocket::SocketError error); void connectionError(QAbstractSocket::SocketError error);
void serviceConnectionError(const QString &service); void serviceConnectionError(const QString &service);
void appendMessage(const QString &msg, Utils::OutputFormat); void appendMessage(const QString &msg, Utils::OutputFormat);