forked from qt-creator/qt-creator
QmlDbg: Don't wait infinitely for messages on application output
We only connect to the port when we get a 'Waiting for connection ...' message on application output. This was done mainly to avoid lots of failed connects, and therefore an unresponsive UI on Windows. However, the application output might be redirected for various reasons. Therefore fall back to busy connect after a certain time (4 seconds for profiling, 8 seconds for debugging). Change-Id: Ie1b943f678ced40c030cc134493a2adf7e3bc9df Reviewed-on: http://codereview.qt.nokia.com/2323 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Christiaan Janssen <christiaan.janssen@nokia.com>
This commit is contained in:
@@ -164,6 +164,7 @@ private:
|
|||||||
QmlAdapter m_adapter;
|
QmlAdapter m_adapter;
|
||||||
ApplicationLauncher m_applicationLauncher;
|
ApplicationLauncher m_applicationLauncher;
|
||||||
Utils::FileInProjectFinder fileFinder;
|
Utils::FileInProjectFinder fileFinder;
|
||||||
|
QTimer m_noDebugOutputTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
QmlEnginePrivate::QmlEnginePrivate(QmlEngine *q)
|
QmlEnginePrivate::QmlEnginePrivate(QmlEngine *q)
|
||||||
@@ -203,6 +204,12 @@ QmlEngine::QmlEngine(const DebuggerStartParameters &startParameters,
|
|||||||
connect(&d->m_applicationLauncher,
|
connect(&d->m_applicationLauncher,
|
||||||
SIGNAL(appendMessage(QString,Utils::OutputFormat)),
|
SIGNAL(appendMessage(QString,Utils::OutputFormat)),
|
||||||
SLOT(appendMessage(QString,Utils::OutputFormat)));
|
SLOT(appendMessage(QString,Utils::OutputFormat)));
|
||||||
|
|
||||||
|
// Only wait 8 seconds for the 'Waiting for connection' on application ouput, then just try to connect
|
||||||
|
// (application output might be redirected / blocked)
|
||||||
|
d->m_noDebugOutputTimer.setSingleShot(true);
|
||||||
|
d->m_noDebugOutputTimer.setInterval(8000);
|
||||||
|
connect(&d->m_noDebugOutputTimer, SIGNAL(timeout()), this, SLOT(beginConnection()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlEngine::~QmlEngine()
|
QmlEngine::~QmlEngine()
|
||||||
@@ -251,6 +258,12 @@ void QmlEngine::connectionEstablished()
|
|||||||
notifyEngineRunAndInferiorRunOk();
|
notifyEngineRunAndInferiorRunOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QmlEngine::beginConnection()
|
||||||
|
{
|
||||||
|
d->m_noDebugOutputTimer.stop();
|
||||||
|
d->m_adapter.beginConnection();
|
||||||
|
}
|
||||||
|
|
||||||
void QmlEngine::connectionStartupFailed()
|
void QmlEngine::connectionStartupFailed()
|
||||||
{
|
{
|
||||||
Core::ICore * const core = Core::ICore::instance();
|
Core::ICore * const core = Core::ICore::instance();
|
||||||
@@ -273,7 +286,7 @@ void QmlEngine::retryMessageBoxFinished(int result)
|
|||||||
{
|
{
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case QMessageBox::Retry: {
|
case QMessageBox::Retry: {
|
||||||
d->m_adapter.beginConnection();
|
beginConnection();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QMessageBox::Help: {
|
case QMessageBox::Help: {
|
||||||
@@ -311,6 +324,9 @@ void QmlEngine::filterApplicationMessage(const QString &msg, int /*channel*/)
|
|||||||
|
|
||||||
const int index = msg.indexOf(qddserver);
|
const int index = msg.indexOf(qddserver);
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
|
// we're actually getting debug output
|
||||||
|
d->m_noDebugOutputTimer.stop();
|
||||||
|
|
||||||
QString status = msg;
|
QString status = msg;
|
||||||
status.remove(0, index + qddserver.length()); // chop of 'QDeclarativeDebugServer: '
|
status.remove(0, index + qddserver.length()); // chop of 'QDeclarativeDebugServer: '
|
||||||
|
|
||||||
@@ -322,7 +338,7 @@ void QmlEngine::filterApplicationMessage(const QString &msg, int /*channel*/)
|
|||||||
|
|
||||||
QString errorMessage;
|
QString errorMessage;
|
||||||
if (status.startsWith(waitingForConnection)) {
|
if (status.startsWith(waitingForConnection)) {
|
||||||
d->m_adapter.beginConnection();
|
beginConnection();
|
||||||
} else if (status.startsWith(unableToListen)) {
|
} else if (status.startsWith(unableToListen)) {
|
||||||
//: Error message shown after 'Could not connect ... debugger:"
|
//: Error message shown after 'Could not connect ... debugger:"
|
||||||
errorMessage = tr("The port seems to be in use.");
|
errorMessage = tr("The port seems to be in use.");
|
||||||
@@ -356,7 +372,7 @@ void QmlEngine::filterApplicationMessage(const QString &msg, int /*channel*/)
|
|||||||
}
|
}
|
||||||
} else if (msg.contains(cannotRetrieveDebuggingOutput)) {
|
} else if (msg.contains(cannotRetrieveDebuggingOutput)) {
|
||||||
// we won't get debugging output, so just try to connect ...
|
// we won't get debugging output, so just try to connect ...
|
||||||
d->m_adapter.beginConnection();
|
beginConnection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,6 +401,7 @@ void QmlEngine::runEngine()
|
|||||||
|
|
||||||
if (!isSlaveEngine() && startParameters().startMode != AttachToRemote)
|
if (!isSlaveEngine() && startParameters().startMode != AttachToRemote)
|
||||||
startApplicationLauncher();
|
startApplicationLauncher();
|
||||||
|
d->m_noDebugOutputTimer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlEngine::startApplicationLauncher()
|
void QmlEngine::startApplicationLauncher()
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ signals:
|
|||||||
TextEditor::ITextEditor *editor, int cursorPos);
|
TextEditor::ITextEditor *editor, int cursorPos);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void beginConnection();
|
||||||
void connectionEstablished();
|
void connectionEstablished();
|
||||||
void connectionStartupFailed();
|
void connectionStartupFailed();
|
||||||
void connectionError(QAbstractSocket::SocketError error);
|
void connectionError(QAbstractSocket::SocketError error);
|
||||||
|
|||||||
@@ -54,6 +54,7 @@
|
|||||||
|
|
||||||
#include <QtGui/QMainWindow>
|
#include <QtGui/QMainWindow>
|
||||||
#include <QtGui/QMessageBox>
|
#include <QtGui/QMessageBox>
|
||||||
|
#include <QtCore/QTimer>
|
||||||
|
|
||||||
using namespace Analyzer;
|
using namespace Analyzer;
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
@@ -83,6 +84,7 @@ public:
|
|||||||
bool m_fetchingData;
|
bool m_fetchingData;
|
||||||
bool m_fetchDataFromStart;
|
bool m_fetchDataFromStart;
|
||||||
bool m_delayedDelete;
|
bool m_delayedDelete;
|
||||||
|
QTimer m_noDebugOutputTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
AbstractQmlProfilerRunner *
|
AbstractQmlProfilerRunner *
|
||||||
@@ -135,6 +137,12 @@ QmlProfilerEngine::QmlProfilerEngine(IAnalyzerTool *tool,
|
|||||||
d->m_fetchingData = false;
|
d->m_fetchingData = false;
|
||||||
d->m_fetchDataFromStart = false;
|
d->m_fetchDataFromStart = false;
|
||||||
d->m_delayedDelete = false;
|
d->m_delayedDelete = false;
|
||||||
|
|
||||||
|
// Only wait 4 seconds for the 'Waiting for connection' on application ouput, then just try to connect
|
||||||
|
// (application output might be redirected / blocked)
|
||||||
|
d->m_noDebugOutputTimer.setSingleShot(true);
|
||||||
|
d->m_noDebugOutputTimer.setInterval(4000);
|
||||||
|
connect(&d->m_noDebugOutputTimer, SIGNAL(timeout()), this, SLOT(processIsRunning()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlProfilerEngine::~QmlProfilerEngine()
|
QmlProfilerEngine::~QmlProfilerEngine()
|
||||||
@@ -174,6 +182,7 @@ bool QmlProfilerEngine::start()
|
|||||||
connect(d->m_runner, SIGNAL(appendMessage(QString,Utils::OutputFormat)),
|
connect(d->m_runner, SIGNAL(appendMessage(QString,Utils::OutputFormat)),
|
||||||
this, SLOT(logApplicationMessage(QString,Utils::OutputFormat)));
|
this, SLOT(logApplicationMessage(QString,Utils::OutputFormat)));
|
||||||
|
|
||||||
|
d->m_noDebugOutputTimer.start();
|
||||||
d->m_runner->start();
|
d->m_runner->start();
|
||||||
|
|
||||||
d->m_running = true;
|
d->m_running = true;
|
||||||
@@ -248,6 +257,9 @@ void QmlProfilerEngine::filterApplicationMessage(const QString &msg)
|
|||||||
|
|
||||||
const int index = msg.indexOf(qddserver);
|
const int index = msg.indexOf(qddserver);
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
|
// we're actually getting debug output
|
||||||
|
d->m_noDebugOutputTimer.stop();
|
||||||
|
|
||||||
QString status = msg;
|
QString status = msg;
|
||||||
status.remove(0, index + qddserver.length()); // chop of 'QDeclarativeDebugServer: '
|
status.remove(0, index + qddserver.length()); // chop of 'QDeclarativeDebugServer: '
|
||||||
|
|
||||||
@@ -259,7 +271,7 @@ void QmlProfilerEngine::filterApplicationMessage(const QString &msg)
|
|||||||
|
|
||||||
QString errorMessage;
|
QString errorMessage;
|
||||||
if (status.startsWith(waitingForConnection)) {
|
if (status.startsWith(waitingForConnection)) {
|
||||||
emit processRunning(d->m_runner->debugPort());
|
processIsRunning();
|
||||||
} else if (status.startsWith(unableToListen)) {
|
} else if (status.startsWith(unableToListen)) {
|
||||||
//: Error message shown after 'Could not connect ... debugger:"
|
//: Error message shown after 'Could not connect ... debugger:"
|
||||||
errorMessage = tr("The port seems to be in use.");
|
errorMessage = tr("The port seems to be in use.");
|
||||||
@@ -291,7 +303,7 @@ void QmlProfilerEngine::filterApplicationMessage(const QString &msg)
|
|||||||
}
|
}
|
||||||
} else if (msg.contains(cannotRetrieveDebuggingOutput)) {
|
} else if (msg.contains(cannotRetrieveDebuggingOutput)) {
|
||||||
// we won't get debugging output, so just try to connect ...
|
// we won't get debugging output, so just try to connect ...
|
||||||
emit processRunning(d->m_runner->debugPort());
|
processIsRunning();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -323,5 +335,11 @@ void QmlProfilerEngine::showNonmodalWarning(const QString &warningMsg)
|
|||||||
noExecWarning->show();
|
noExecWarning->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QmlProfilerEngine::processIsRunning()
|
||||||
|
{
|
||||||
|
d->m_noDebugOutputTimer.stop();
|
||||||
|
emit processRunning(d->m_runner->debugPort());
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace QmlProfiler
|
} // namespace QmlProfiler
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ private slots:
|
|||||||
void logApplicationMessage(const QString &msg, Utils::OutputFormat format);
|
void logApplicationMessage(const QString &msg, Utils::OutputFormat format);
|
||||||
void filterApplicationMessage(const QString &msg);
|
void filterApplicationMessage(const QString &msg);
|
||||||
void wrongSetupMessageBoxFinished(int);
|
void wrongSetupMessageBoxFinished(int);
|
||||||
|
void processIsRunning();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class QmlProfilerEnginePrivate;
|
class QmlProfilerEnginePrivate;
|
||||||
|
|||||||
Reference in New Issue
Block a user