aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp')
-rw-r--r--src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp111
1 files changed, 66 insertions, 45 deletions
diff --git a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
index a5f9ed9a1a..bc259afaa4 100644
--- a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
+++ b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
@@ -186,6 +186,7 @@ private:
QStringList m_clientPlugins;
bool m_gotHello;
bool m_blockingMode;
+ bool m_clientSupportsMultiPackets;
QHash<QJSEngine *, EngineCondition> m_engineConditions;
@@ -274,7 +275,8 @@ static void cleanupOnShutdown()
QQmlDebugServerImpl::QQmlDebugServerImpl() :
m_connection(0),
m_gotHello(false),
- m_blockingMode(false)
+ m_blockingMode(false),
+ m_clientSupportsMultiPackets(false)
{
static bool postRoutineAdded = false;
if (!postRoutineAdded) {
@@ -327,7 +329,6 @@ bool QQmlDebugServerImpl::open(const QVariantHash &configuration = QVariantHash(
return true;
}
-#define qUsage qWarning().noquote().nospace
void QQmlDebugServerImpl::parseArguments()
{
// format: qmljsdebugger=port:<port_from>[,port_to],host:<ip address>][,block]
@@ -376,8 +377,9 @@ void QQmlDebugServerImpl::parseArguments()
} else if (!services.isEmpty()) {
services.append(strArgument);
} else {
- qUsage() << tr("QML Debugger: Invalid argument \"%1\" detected. Ignoring the same.")
- .arg(strArgument);
+ const QString message = tr("QML Debugger: Invalid argument \"%1\" detected."
+ " Ignoring the same.").arg(strArgument);
+ qWarning("%s", qPrintable(message));
}
}
@@ -389,43 +391,47 @@ void QQmlDebugServerImpl::parseArguments()
else
m_thread.setPortRange(portFrom, portTo, hostAddress);
} else {
- qUsage() << tr("QML Debugger: Ignoring \"-qmljsdebugger=%1\".").arg(args);
- qUsage() << tr("The format is \"-qmljsdebugger=[file:<file>|port:<port_from>][,<port_to>]"
- "[,host:<ip address>][,block][,services:<service>][,<service>]*\"\n");
- qUsage() << tr("\"file:\" can be used to specify the name of a file the debugger will try "
- "to connect to using a QLocalSocket. If \"file:\" is given any \"host:\" and"
- "\"port:\" arguments will be ignored.\n");
- qUsage() << tr("\"host:\" and \"port:\" can be used to specify an address and a single "
- "port or a range of ports the debugger will try to bind to with a "
- "QTcpServer.\n");
- qUsage() << tr("\"block\" makes the debugger and some services wait for clients to be "
- "connected and ready before the first QML engine starts.\n");
- qUsage() << tr("\"services:\" can be used to specify which debug services the debugger "
- "should load. Some debug services interact badly with others. The V4 "
- "debugger should not be loaded when using the QML profiler as it will force "
- "any V4 engines to use the JavaScript interpreter rather than the JIT. The "
- "following debug services are available by default:");
- qUsage() << QQmlEngineDebugService::s_key << tr("\t- The QML debugger");
- qUsage() << QV4DebugService::s_key << tr("\t- The V4 debugger");
- qUsage() << QQmlInspectorService::s_key << tr("\t- The QML inspector");
- qUsage() << QQmlProfilerService::s_key << tr("\t- The QML profiler");
- qUsage() << QQmlEngineControlService::s_key
- << tr("\t- Allows the client to delay the starting and stopping of\n"
- "\t\t QML engines until other services are ready. QtCreator\n"
- "\t\t uses this service with the QML profiler in order to\n"
- "\t\t profile multiple QML engines at the same time.");
- qUsage() << QDebugMessageService::s_key
- << tr("\t- Sends qDebug() and similar messages over the QML debug\n"
- "\t\t connection. QtCreator uses this for showing debug\n"
- "\t\t messages in the JavaScript console.");
- qUsage() << tr("Other services offered by qmltooling plugins that implement "
- "QQmlDebugServiceFactory and which can be found in the standard plugin "
- "paths will also be available and can be specified. If no \"services\" "
- "argument is given, all services found this way, including the default "
- "ones, are loaded.");
+ QString usage;
+ QTextStream str(&usage);
+ str << tr("QML Debugger: Ignoring \"-qmljsdebugger=%1\".").arg(args) << '\n'
+ << tr("The format is \"-qmljsdebugger=[file:<file>|port:<port_from>][,<port_to>]"
+ "[,host:<ip address>][,block][,services:<service>][,<service>]*\"") << '\n'
+ << tr("\"file:\" can be used to specify the name of a file the debugger will try "
+ "to connect to using a QLocalSocket. If \"file:\" is given any \"host:\" and"
+ "\"port:\" arguments will be ignored.") << '\n'
+ << tr("\"host:\" and \"port:\" can be used to specify an address and a single "
+ "port or a range of ports the debugger will try to bind to with a "
+ "QTcpServer.") << '\n'
+ << tr("\"block\" makes the debugger and some services wait for clients to be "
+ "connected and ready before the first QML engine starts.") << '\n'
+ << tr("\"services:\" can be used to specify which debug services the debugger "
+ "should load. Some debug services interact badly with others. The V4 "
+ "debugger should not be loaded when using the QML profiler as it will force "
+ "any V4 engines to use the JavaScript interpreter rather than the JIT. The "
+ "following debug services are available by default:") << '\n'
+ << QQmlEngineDebugService::s_key << "\t- " << tr("The QML debugger") << '\n'
+ << QV4DebugService::s_key << "\t- " << tr("The V4 debugger") << '\n'
+ << QQmlInspectorService::s_key << "\t- " << tr("The QML inspector") << '\n'
+ << QQmlProfilerService::s_key << "\t- " << tr("The QML profiler") << '\n'
+ << QQmlEngineControlService::s_key << "\t- "
+ //: Please preserve the line breaks and formatting
+ << tr("Allows the client to delay the starting and stopping of\n"
+ "\t\t QML engines until other services are ready. QtCreator\n"
+ "\t\t uses this service with the QML profiler in order to\n"
+ "\t\t profile multiple QML engines at the same time.")
+ << '\n' << QDebugMessageService::s_key << "\t- "
+ //: Please preserve the line breaks and formatting
+ << tr("Sends qDebug() and similar messages over the QML debug\n"
+ "\t\t connection. QtCreator uses this for showing debug\n"
+ "\t\t messages in the JavaScript console.") << '\n'
+ << tr("Other services offered by qmltooling plugins that implement "
+ "QQmlDebugServiceFactory and which can be found in the standard plugin "
+ "paths will also be available and can be specified. If no \"services\" "
+ "argument is given, all services found this way, including the default "
+ "ones, are loaded.");
+ qWarning("%s", qPrintable(usage));
}
}
-#undef qUsage
void QQmlDebugServerImpl::receiveMessage()
{
@@ -456,6 +462,11 @@ void QQmlDebugServerImpl::receiveMessage()
s_dataStreamVersion = QDataStream::Qt_DefaultCompiledVersion;
}
+ if (!in.atEnd())
+ in >> m_clientSupportsMultiPackets;
+ else
+ m_clientSupportsMultiPackets = false;
+
// Send the hello answer immediately, since it needs to arrive before
// the plugins below start sending messages.
@@ -516,14 +527,16 @@ void QQmlDebugServerImpl::receiveMessage()
} else {
if (m_gotHello) {
- QByteArray message;
- in >> message;
-
QHash<QString, QQmlDebugService *>::Iterator iter = m_plugins.find(name);
if (iter == m_plugins.end()) {
qWarning() << "QML Debugger: Message received for missing plugin" << name << '.';
} else {
- (*iter)->messageReceived(message);
+ QQmlDebugService *service = *iter;
+ QByteArray message;
+ while (!in.atEnd()) {
+ in >> message;
+ service->messageReceived(message);
+ }
}
} else {
qWarning("QML Debugger: Invalid hello message.");
@@ -686,8 +699,16 @@ void QQmlDebugServerImpl::sendMessage(const QString &name, const QByteArray &mes
void QQmlDebugServerImpl::sendMessages(const QString &name, const QList<QByteArray> &messages)
{
if (canSendMessage(name)) {
- foreach (const QByteArray &message, messages)
- doSendMessage(name, message);
+ if (m_clientSupportsMultiPackets) {
+ QQmlDebugPacket out;
+ out << name;
+ foreach (const QByteArray &message, messages)
+ out << message;
+ m_protocol->send(out.data());
+ } else {
+ foreach (const QByteArray &message, messages)
+ doSendMessage(name, message);
+ }
m_connection->flush();
}
}