Unify parsing of application output in Debugger and Profiler

Change-Id: I8711f39aa44fea7d1a7091a27d77f5e73d5e4291
Reviewed-by: Aurindam Jana <aurindam.jana@nokia.com>
This commit is contained in:
Kai Koehne
2011-10-31 16:42:31 +01:00
parent 3a4710e780
commit 8f7411fdad
8 changed files with 253 additions and 135 deletions

View File

@@ -51,6 +51,7 @@
#include <projectexplorer/applicationrunconfiguration.h>
#include <qt4projectmanager/qt-s60/s60devicedebugruncontrol.h>
#include <qt4projectmanager/qt-s60/s60devicerunconfiguration.h>
#include <qmljsdebugclient/qdeclarativeoutputparser.h>
#include <QtGui/QMainWindow>
#include <QtGui/QMessageBox>
@@ -85,6 +86,7 @@ public:
bool m_fetchDataFromStart;
bool m_delayedDelete;
QTimer m_noDebugOutputTimer;
QmlJsDebugClient::QDeclarativeOutputParser m_outputParser;
};
AbstractQmlProfilerRunner *
@@ -146,6 +148,14 @@ QmlProfilerEngine::QmlProfilerEngine(IAnalyzerTool *tool,
d->m_noDebugOutputTimer.setSingleShot(true);
d->m_noDebugOutputTimer.setInterval(4000);
connect(&d->m_noDebugOutputTimer, SIGNAL(timeout()), this, SLOT(processIsRunning()));
d->m_outputParser.setNoOutputText(ApplicationLauncher::msgWinCannotRetrieveDebuggingOutput());
connect(&d->m_outputParser, SIGNAL(waitingForConnectionMessage()),
this, SLOT(processIsRunning()));
connect(&d->m_outputParser, SIGNAL(noOutputMessage()),
this, SLOT(processIsRunning()));
connect(&d->m_outputParser, SIGNAL(errorMessage(QString)),
this, SLOT(wrongSetupMessageBox(QString)));
}
QmlProfilerEngine::~QmlProfilerEngine()
@@ -259,72 +269,33 @@ void QmlProfilerEngine::finishProcess()
}
}
void QmlProfilerEngine::filterApplicationMessage(const QString &msg)
{
static const QString qddserver = QLatin1String("QDeclarativeDebugServer: ");
static const QString cannotRetrieveDebuggingOutput = ProjectExplorer::ApplicationLauncher::msgWinCannotRetrieveDebuggingOutput();
const int index = msg.indexOf(qddserver);
if (index != -1) {
// we're actually getting debug output
d->m_noDebugOutputTimer.stop();
QString status = msg;
status.remove(0, index + qddserver.length()); // chop of 'QDeclarativeDebugServer: '
static QString waitingForConnection = QLatin1String("Waiting for connection ");
static QString unableToListen = QLatin1String("Unable to listen ");
static QString debuggingNotEnabled = QLatin1String("Ignoring \"-qmljsdebugger=");
static QString debuggingNotEnabled2 = QLatin1String("Ignoring\"-qmljsdebugger="); // There is (was?) a bug in one of the error strings - safest to handle both
static QString connectionEstablished = QLatin1String("Connection established");
QString errorMessage;
if (status.startsWith(waitingForConnection)) {
processIsRunning();
} else if (status.startsWith(unableToListen)) {
//: Error message shown after 'Could not connect ... debugger:"
errorMessage = tr("The port seems to be in use.");
} else if (status.startsWith(debuggingNotEnabled) || status.startsWith(debuggingNotEnabled2)) {
//: Error message shown after 'Could not connect ... debugger:"
errorMessage = tr("The application is not set up for QML/JS debugging.");
} else if (status.startsWith(connectionEstablished)) {
// nothing to do
} else {
qWarning() << "Unknown QDeclarativeDebugServer status message: " << status;
}
if (!errorMessage.isEmpty()) {
Core::ICore * const core = Core::ICore::instance();
QMessageBox *infoBox = new QMessageBox(core->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();
d->m_running = false;
AnalyzerManager::stopTool();
emit finished();
}
} else if (msg.contains(cannotRetrieveDebuggingOutput)) {
// we won't get debugging output, so just try to connect ...
processIsRunning();
}
}
void QmlProfilerEngine::logApplicationMessage(const QString &msg, Utils::OutputFormat format)
{
emit outputReceived(msg, format);
d->m_outputParser.processOutput(msg);
}
filterApplicationMessage(msg);
void QmlProfilerEngine::wrongSetupMessageBox(const QString &errorMessage)
{
Core::ICore * const core = Core::ICore::instance();
QMessageBox *infoBox = new QMessageBox(core->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();
d->m_running = false;
AnalyzerManager::stopTool();
emit finished();
}
void QmlProfilerEngine::wrongSetupMessageBoxFinished(int button)