Commit 6668ee13 authored by Aurindam Jana's avatar Aurindam Jana

QmlCppDebugger: Shutdown engine on port busy

Shutdown the debugger engines when the qmljsdebugger port
is busy.

Change-Id: If7f470b04bae26f3bac11863f697b260b463ca4e
Reviewed-by: default avatarKai Koehne <kai.koehne@nokia.com>
parent 69ab35d1
......@@ -790,6 +790,8 @@ void QmlCppEngine::slaveEngineStateChanged
QTC_ASSERT(state() == InferiorRunRequested, qDebug() << state());
notifyInferiorRunOk();
}
} else if (newState == EngineRunFailed) {
d->m_cppEngine->quitDebugger();
}
}
}
......
......@@ -179,7 +179,7 @@ QmlEngine::QmlEngine(const DebuggerStartParameters &startParameters,
connect(&d->m_outputParser, SIGNAL(noOutputMessage()),
this, SLOT(beginConnection()));
connect(&d->m_outputParser, SIGNAL(errorMessage(QString)),
this, SLOT(wrongSetupMessageBox(QString)));
this, SLOT(connectionStartupFailed(QString)));
// Only wait 8 seconds for the 'Waiting for connection' on application ouput, then just try to connect
// (application output might be redirected / blocked)
......@@ -262,7 +262,7 @@ void QmlEngine::beginConnection(quint16 port)
}
}
void QmlEngine::connectionStartupFailed()
void QmlEngine::connectionStartupFailed(const QString &errorMessage)
{
if (isSlaveEngine()) {
if (masterEngine()->state() != InferiorRunOk) {
......@@ -275,19 +275,28 @@ void QmlEngine::connectionStartupFailed()
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"
"Do you want to retry?"));
infoBox->setStandardButtons(QMessageBox::Retry | QMessageBox::Cancel | QMessageBox::Help);
infoBox->setDefaultButton(QMessageBox::Retry);
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->setModal(true);
connect(infoBox, SIGNAL(finished(int)),
this, SLOT(retryMessageBoxFinished(int)));
this, SLOT(errorMessageBoxFinished(int)));
infoBox->show();
}
void QmlEngine::retryMessageBoxFinished(int result)
void QmlEngine::errorMessageBoxFinished(int result)
{
switch (result) {
case QMessageBox::Retry: {
......@@ -304,33 +313,12 @@ void QmlEngine::retryMessageBoxFinished(int result)
notifyInferiorSpontaneousStop();
notifyInferiorIll();
} else {
notifyEngineRunFailed();
notifyEngineRunFailed();
}
break;
}
}
void QmlEngine::wrongSetupMessageBox(const QString &errorMessage)
{
d->m_noDebugOutputTimer.stop();
notifyEngineRunFailed();
QMessageBox *infoBox = new QMessageBox(Core::ICore::mainWindow());
infoBox->setIcon(QMessageBox::Critical);
infoBox->setWindowTitle(tr("Qt Creator"));
//: %1 is detailed error message
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);
connect(infoBox, SIGNAL(finished(int)),
this, SLOT(wrongSetupMessageBoxFinished(int)));
infoBox->show();
}
void QmlEngine::connectionError(QAbstractSocket::SocketError socketError)
{
if (socketError == QAbstractSocket::RemoteHostClosedError)
......@@ -864,15 +852,6 @@ void QmlEngine::disconnected()
notifyInferiorExited();
}
void QmlEngine::wrongSetupMessageBoxFinished(int result)
{
if (result == QMessageBox::Help) {
Core::HelpManager *helpManager = Core::HelpManager::instance();
helpManager->handleHelpRequest(
QLatin1String("qthelp://com.nokia.qtcreator/doc/creator-debugging-qml.html"));
}
}
void QmlEngine::updateCurrentContext()
{
const QString context = state() == InferiorStopOk ?
......
......@@ -94,9 +94,7 @@ public slots:
void disconnected();
private slots:
void retryMessageBoxFinished(int result);
void wrongSetupMessageBox(const QString &errorMessage);
void wrongSetupMessageBoxFinished(int result);
void errorMessageBoxFinished(int result);
void updateCurrentContext();
void appendDebugOutput(QtMsgType type, const QString &message,
const QmlJsDebugClient::QDebugContextInfo &info);
......@@ -162,7 +160,7 @@ signals:
private slots:
void beginConnection(quint16 port = 0);
void connectionEstablished();
void connectionStartupFailed();
void connectionStartupFailed(const QString &errorMessage = QString());
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