Commit ccc55a61 authored by Kai Koehne's avatar Kai Koehne

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: default avatarAurindam Jana <aurindam.jana@nokia.com>
parent cbc328e2
......@@ -346,7 +346,7 @@ QmlEngine::QmlEngine(const DebuggerStartParameters &startParameters,
connect(&d->m_outputParser, SIGNAL(noOutputMessage()),
this, SLOT(beginConnection()));
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
// (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 (masterEngine()->state() != InferiorRunOk) {
......@@ -447,19 +447,11 @@ void QmlEngine::connectionStartupFailed(const QString &errorMessage)
QMessageBox *infoBox = new QMessageBox(Core::ICore::mainWindow());
infoBox->setIcon(QMessageBox::Critical);
infoBox->setWindowTitle(tr("Qt Creator"));
if (qobject_cast<QmlAdapter *>(sender())) {
infoBox->setText(tr("Could not connect to the in-process QML debugger."
"\nDo you want to retry?"));
infoBox->setStandardButtons(QMessageBox::Retry | QMessageBox::Cancel |
QMessageBox::Help);
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->setText(tr("Could not connect to the in-process QML debugger."
"\nDo you want to retry?"));
infoBox->setStandardButtons(QMessageBox::Retry | QMessageBox::Cancel |
QMessageBox::Help);
infoBox->setDefaultButton(QMessageBox::Retry);
infoBox->setModal(true);
connect(infoBox, SIGNAL(finished(int)),
......@@ -468,6 +460,22 @@ void QmlEngine::connectionStartupFailed(const QString &errorMessage)
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)
{
switch (result) {
......@@ -484,7 +492,7 @@ void QmlEngine::errorMessageBoxFinished(int result)
if (state() == InferiorRunOk) {
notifyInferiorSpontaneousStop();
notifyInferiorIll();
} else {
} else if (state() == EngineRunRequested) {
notifyEngineRunFailed();
}
break;
......
......@@ -163,7 +163,8 @@ signals:
private slots:
void beginConnection(quint16 port = 0);
void connectionEstablished();
void connectionStartupFailed(const QString &errorMessage = QString());
void connectionStartupFailed();
void appStartupFailed(const QString &errorMessage);
void connectionError(QAbstractSocket::SocketError error);
void serviceConnectionError(const QString &service);
void appendMessage(const QString &msg, Utils::OutputFormat);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment