From 2f51579fe4bf947784135f02e10f129cc75ad695 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@nokia.com> Date: Wed, 22 Aug 2012 11:58:33 +0200 Subject: [PATCH] Debugger: Fix string usages. - Compile with QT_NO_CAST_FROM_ASCII. - Remove single character string constants. Change-Id: Icece98619b6c30e047d3fce00e6ae74bbcd53c67 Reviewed-by: hjk <qthjk@ovi.com> --- src/plugins/debugger/cdb/cdbparsehelpers.cpp | 2 +- src/plugins/debugger/debuggeractions.cpp | 9 +- src/plugins/debugger/debuggerplugin.cpp | 8 +- src/plugins/debugger/gdb/coregdbadapter.cpp | 8 +- .../debugger/gdb/startgdbserverdialog.cpp | 2 +- src/plugins/debugger/loadcoredialog.cpp | 4 +- .../namedemangler/demanglerexceptions.h | 2 +- .../debugger/namedemangler/namedemangler.cpp | 6 +- .../debugger/namedemangler/parsetreenodes.cpp | 45 ++++---- src/plugins/debugger/pdb/pdbengine.cpp | 6 +- .../debugger/qml/qmlinspectoradapter.cpp | 10 +- .../debugger/qml/qmlinspectoragent.cpp | 100 +++++++++--------- .../debugger/qml/qmllivetextpreview.cpp | 8 +- .../debugger/qml/qmlv8debuggerclient.cpp | 12 ++- src/plugins/debugger/snapshothandler.cpp | 2 +- src/plugins/debugger/watchhandler.cpp | 4 +- 16 files changed, 127 insertions(+), 101 deletions(-) diff --git a/src/plugins/debugger/cdb/cdbparsehelpers.cpp b/src/plugins/debugger/cdb/cdbparsehelpers.cpp index 59e0a01b363..5e886553af9 100644 --- a/src/plugins/debugger/cdb/cdbparsehelpers.cpp +++ b/src/plugins/debugger/cdb/cdbparsehelpers.cpp @@ -182,7 +182,7 @@ QByteArray cdbAddBreakpointCommand(const BreakpointParameters &bpIn, break; case WatchpointAtAddress: { // Read/write, no space here const unsigned size = bp.size ? bp.size : 1; - str << "r" << size << ' ' << hex << hexPrefixOn << bp.address << hexPrefixOff << dec; + str << 'r' << size << ' ' << hex << hexPrefixOn << bp.address << hexPrefixOff << dec; } break; } diff --git a/src/plugins/debugger/debuggeractions.cpp b/src/plugins/debugger/debuggeractions.cpp index 354b87d4e21..f912e3d9d84 100644 --- a/src/plugins/debugger/debuggeractions.cpp +++ b/src/plugins/debugger/debuggeractions.cpp @@ -28,6 +28,8 @@ ** **************************************************************************/ +#define QT_NO_CAST_FROM_ASCII + #include "debuggeractions.h" #include "debuggerconstants.h" @@ -551,8 +553,9 @@ DebuggerSettings::DebuggerSettings(QSettings *settings) item->setDefaultValue(true); insertItem(ShowQmlObjectTree, item); + const QString qmlInspectorGroup = QLatin1String("QML.Inspector"); item = new SavedAction(this); - item->setSettingsKey("QML.Inspector", QLatin1String("QmlInspector.ShowAppOnTop")); + item->setSettingsKey(qmlInspectorGroup, QLatin1String("QmlInspector.ShowAppOnTop")); item->setText(tr("Show Application On Top")); item->setCheckable(true); item->setDefaultValue(false); @@ -560,7 +563,7 @@ DebuggerSettings::DebuggerSettings(QSettings *settings) insertItem(ShowAppOnTop, item); item = new SavedAction(this); - item->setSettingsKey("QML.Inspector", QLatin1String("QmlInspector.FromQml")); + item->setSettingsKey(qmlInspectorGroup, QLatin1String("QmlInspector.FromQml")); item->setText(tr("Apply Changes on Save")); item->setCheckable(true); item->setDefaultValue(false); @@ -611,7 +614,7 @@ QString DebuggerSettings::dump() const const QString current = item->value().toString(); const QString default_ = item->defaultValue().toString(); ts << '\n' << key << ": " << current - << " (default: " << default_ << ")"; + << " (default: " << default_ << ')'; if (current != default_) ts << " ***"; } diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 9efea5a1d28..21390100d19 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -28,6 +28,8 @@ ** **************************************************************************/ +#define QT_NO_CAST_FROM_ASCII + #include "debuggerplugin.h" #include "debuggerstartparameters.h" @@ -563,7 +565,7 @@ void fillParameters(DebuggerStartParameters *sp, Profile *profile) IDevice::ConstPtr device = DeviceProfileInformation::device(profile); if (device) { sp->connParams = device->sshParameters(); - sp->remoteChannel = QString("%1:%2").arg(sp->connParams.host).arg(sp->connParams.port); + sp->remoteChannel = sp->connParams.host + QLatin1Char(':') + QString::number(sp->connParams.port); } } @@ -3398,7 +3400,7 @@ void DebuggerPluginPrivate::testPythonDumpers1() { m_testSuccess = true; QString proFile = ICore::resourcePath() - + "/../../tests/manual/debugger/simple/simple.pro"; + + QLatin1String("/../../tests/manual/debugger/simple/simple.pro"); testLoadProject(proFile, TestCallBack(this, "testPythonDumpers2")); QVERIFY(m_testSuccess); QTestEventLoop::instance().enterLoop(20); @@ -3430,7 +3432,7 @@ void DebuggerPluginPrivate::testStateMachine1() { m_testSuccess = true; QString proFile = ICore::resourcePath() - + "/../../tests/manual/debugger/simple/simple.pro"; + + QLatin1String("/../../tests/manual/debugger/simple/simple.pro"); testLoadProject(proFile, TestCallBack(this, "testStateMachine2")); QVERIFY(m_testSuccess); QTestEventLoop::instance().enterLoop(20); diff --git a/src/plugins/debugger/gdb/coregdbadapter.cpp b/src/plugins/debugger/gdb/coregdbadapter.cpp index f6ca7af3665..0defb237fc7 100644 --- a/src/plugins/debugger/gdb/coregdbadapter.cpp +++ b/src/plugins/debugger/gdb/coregdbadapter.cpp @@ -28,6 +28,8 @@ ** **************************************************************************/ +#define QT_NO_CAST_FROM_ASCII + #include "coregdbadapter.h" #include "debuggerstartparameters.h" @@ -94,7 +96,7 @@ void GdbCoreEngine::continueSetupEngine() // Read executable from core. ElfReader reader(coreFileName()); bool isCore = false; - m_executable = reader.readCoreName(&isCore); + m_executable = QString::fromLocal8Bit(reader.readCoreName(&isCore)); if (!isCore) { showMessageBox(QMessageBox::Warning, @@ -212,7 +214,9 @@ void GdbCoreEngine::unpackCoreIfNeeded() QProcess *process = new QProcess(this); process->setWorkingDirectory(QDir::tempPath()); - process->start("/usr/bin/lzop", QStringList() << "-o" << m_tempCoreName << "-x" << m_coreName); + QStringList arguments; + arguments << QLatin1String("-o") << m_tempCoreName << QLatin1String("-x") << m_coreName; + process->start(QLatin1String("/usr/bin/lzop"), arguments); connect(process, SIGNAL(finished(int)), SLOT(continueSetupEngine())); } diff --git a/src/plugins/debugger/gdb/startgdbserverdialog.cpp b/src/plugins/debugger/gdb/startgdbserverdialog.cpp index 86537385eb9..dbeaea6dc2a 100644 --- a/src/plugins/debugger/gdb/startgdbserverdialog.cpp +++ b/src/plugins/debugger/gdb/startgdbserverdialog.cpp @@ -129,7 +129,7 @@ void GdbServerStarter::portListReady() connect(&d->runner, SIGNAL(processClosed(int)), SLOT(handleProcessClosed(int))); QByteArray cmd = "/usr/bin/gdbserver --attach :" - + QByteArray::number(port) + " " + QByteArray::number(d->process.pid); + + QByteArray::number(port) + ' ' + QByteArray::number(d->process.pid); logMessage(tr("Running command: %1").arg(QString::fromLatin1(cmd))); d->runner.run(cmd, d->device->sshParameters()); } diff --git a/src/plugins/debugger/loadcoredialog.cpp b/src/plugins/debugger/loadcoredialog.cpp index 2d9378d94fa..888d6361b70 100644 --- a/src/plugins/debugger/loadcoredialog.cpp +++ b/src/plugins/debugger/loadcoredialog.cpp @@ -28,6 +28,8 @@ ** **************************************************************************/ +#define QT_NO_CAST_FROM_ASCII + #include "loadcoredialog.h" #include "debuggerconstants.h" @@ -203,7 +205,7 @@ void SelectRemoteFileDialog::selectFile() SLOT(handleSftpOperationFinished(QSsh::SftpJobId,QString))); { - QTemporaryFile localFile(QDir::tempPath() + "/remotecore-XXXXXX"); + QTemporaryFile localFile(QDir::tempPath() + QLatin1String("/remotecore-XXXXXX")); localFile.open(); m_localFile = localFile.fileName(); } diff --git a/src/plugins/debugger/namedemangler/demanglerexceptions.h b/src/plugins/debugger/namedemangler/demanglerexceptions.h index 815801085ea..7fb5e466860 100644 --- a/src/plugins/debugger/namedemangler/demanglerexceptions.h +++ b/src/plugins/debugger/namedemangler/demanglerexceptions.h @@ -61,7 +61,7 @@ public: #define DEMANGLER_ASSERT(cond) \ do { \ if (!(cond)) { \ - throw InternalDemanglerException(Q_FUNC_INFO, __FILE__, __LINE__); \ + throw InternalDemanglerException(QLatin1String(Q_FUNC_INFO), QLatin1String(__FILE__), __LINE__); \ } \ } while (0) diff --git a/src/plugins/debugger/namedemangler/namedemangler.cpp b/src/plugins/debugger/namedemangler/namedemangler.cpp index 09becca5a44..b79490dc0b0 100644 --- a/src/plugins/debugger/namedemangler/namedemangler.cpp +++ b/src/plugins/debugger/namedemangler/namedemangler.cpp @@ -28,6 +28,8 @@ ** **************************************************************************/ +#define QT_NO_CAST_FROM_ASCII + #include "namedemangler.h" #include "demanglerexceptions.h" @@ -61,7 +63,7 @@ bool NameDemanglerPrivate::demangle(const QString &mangledName) m_demangledName.clear(); if (!MangledNameRule::mangledRepresentationStartsWith(m_parseState.peek())) { - m_demangledName = m_parseState.m_mangledName; + m_demangledName = QLatin1String(m_parseState.m_mangledName); return true; } @@ -76,7 +78,7 @@ bool NameDemanglerPrivate::demangle(const QString &mangledName) // Uncomment for debugging. //m_parseState.stackTop()->print(0); - m_demangledName = m_parseState.stackTop()->toByteArray(); + m_demangledName = QLatin1String(m_parseState.stackTop()->toByteArray()); success = true; } catch (const ParseException &p) { m_errorString = QString::fromLocal8Bit("Parse error at index %1 of mangled name '%2': %3.") diff --git a/src/plugins/debugger/namedemangler/parsetreenodes.cpp b/src/plugins/debugger/namedemangler/parsetreenodes.cpp index 729ddcebd56..e423152b23c 100644 --- a/src/plugins/debugger/namedemangler/parsetreenodes.cpp +++ b/src/plugins/debugger/namedemangler/parsetreenodes.cpp @@ -27,6 +27,9 @@ ** ** **************************************************************************/ + +#define QT_NO_CAST_FROM_ASCII + #include "parsetreenodes.h" #include "demanglerexceptions.h" @@ -50,7 +53,7 @@ #define PARSE_RULE_AND_ADD_RESULT_AS_CHILD(nodeType) \ PARSE_RULE_AND_ADD_RESULT_AS_CHILD_TO_NODE(nodeType, parseState(), this) -#define CHILD_AT(obj, index) obj->childAt(index, Q_FUNC_INFO, __FILE__, __LINE__) +#define CHILD_AT(obj, index) obj->childAt(index, QLatin1String(Q_FUNC_INFO), QLatin1String(__FILE__), __LINE__) #define MY_CHILD_AT(index) CHILD_AT(this, index) #define CHILD_TO_BYTEARRAY(index) MY_CHILD_AT(index)->toByteArray() @@ -693,7 +696,7 @@ void ExpressionNode::parse() while (ExpressionNode::mangledRepresentationStartsWith(PEEK())) PARSE_RULE_AND_ADD_RESULT_AS_CHILD(ExpressionNode); if (ADVANCE() != '_') - throw ParseException("Invalid expression"); + throw ParseException(QLatin1String("Invalid expression")); PARSE_RULE_AND_ADD_RESULT_AS_CHILD(TypeNode); if (PEEK() == 'E') ADVANCE(); @@ -2074,7 +2077,7 @@ void NumberNode::parse() { const char next = PEEK(); if (!mangledRepresentationStartsWith(next)) - throw ParseException("Invalid number"); + throw ParseException(QLatin1String("Invalid number")); if (next == 'n') { m_isNegative = true; @@ -2799,15 +2802,15 @@ QByteArray LambdaSigNode::toByteArray() const void ClosureTypeNameNode::parse() { if (parseState()->readAhead(2) != "Ul") - throw ParseException("Invalid closure-type-name"); + throw ParseException(QLatin1String("Invalid closure-type-name")); parseState()->advance(2); PARSE_RULE_AND_ADD_RESULT_AS_CHILD(LambdaSigNode); if (ADVANCE() != 'E') - throw ParseException("invalid closure-type-name"); + throw ParseException(QLatin1String("invalid closure-type-name")); if (NonNegativeNumberNode<10>::mangledRepresentationStartsWith(PEEK())) PARSE_RULE_AND_ADD_RESULT_AS_CHILD(NonNegativeNumberNode<10>); if (ADVANCE() != '_') - throw ParseException("Invalid closure-type-name"); + throw ParseException(QLatin1String("Invalid closure-type-name")); } QByteArray ClosureTypeNameNode::toByteArray() const @@ -2841,7 +2844,7 @@ void UnnamedTypeNameNode::parse() if (NonNegativeNumberNode<10>::mangledRepresentationStartsWith(PEEK())) PARSE_RULE_AND_ADD_RESULT_AS_CHILD(NonNegativeNumberNode<10>); if (ADVANCE() != '_') - throw ParseException("Invalid unnamed-type-node"); + throw ParseException(QLatin1String("Invalid unnamed-type-node")); } else { PARSE_RULE_AND_ADD_RESULT_AS_CHILD(ClosureTypeNameNode); } @@ -2877,7 +2880,7 @@ void DeclTypeNode::parse() { const QByteArray start = parseState()->readAhead(2); if (start != "DT" && start != "Dt") - throw ParseException("Invalid decltype"); + throw ParseException(QLatin1String("Invalid decltype")); parseState()->advance(2); PARSE_RULE_AND_ADD_RESULT_AS_CHILD(ExpressionNode); if (ADVANCE() != 'E') @@ -2913,7 +2916,7 @@ void UnresolvedTypeRule::parse(GlobalParseState *parseState) else if (SubstitutionNode::mangledRepresentationStartsWith(next)) PARSE_RULE_AND_ADD_RESULT_AS_CHILD_TO_NODE(SubstitutionNode, parseState, parentNode); else - throw ParseException("Invalid unresolved-type"); + throw ParseException(QLatin1String("Invalid unresolved-type")); } @@ -2954,7 +2957,7 @@ void DestructorNameNode::parse() else if (SimpleIdNode::mangledRepresentationStartsWith(next)) PARSE_RULE_AND_ADD_RESULT_AS_CHILD(SimpleIdNode); else - throw ParseException("Invalid destructor-name"); + throw ParseException(QLatin1String("Invalid destructor-name")); } QByteArray DestructorNameNode::toByteArray() const @@ -3011,7 +3014,7 @@ void BaseUnresolvedNameNode::parse() parseState()->advance(2); PARSE_RULE_AND_ADD_RESULT_AS_CHILD(DestructorNameNode); } else { - throw ParseException("Invalid <base-unresolved-name>"); + throw ParseException(QLatin1String("Invalid <base-unresolved-name>")); } } @@ -3038,12 +3041,12 @@ bool InitializerNode::mangledRepresentationStartsWith(char c) void InitializerNode::parse() { if (parseState()->readAhead(2) != "pi") - throw ParseException("Invalid initializer"); + throw ParseException(QLatin1String("Invalid initializer")); parseState()->advance(2); while (ExpressionNode::mangledRepresentationStartsWith(PEEK())) PARSE_RULE_AND_ADD_RESULT_AS_CHILD(ExpressionNode); if (ADVANCE() != 'E') - throw ParseException("Invalid initializer"); + throw ParseException(QLatin1String("Invalid initializer")); } QByteArray InitializerNode::toByteArray() const @@ -3093,20 +3096,20 @@ void UnresolvedNameNode::parse() UnresolvedQualifierLevelRule::parse(parseState()); while (UnresolvedQualifierLevelRule::mangledRepresentationStartsWith(PEEK())); if (ADVANCE() != 'E') - throw ParseException("Invalid unresolev-name"); + throw ParseException(QLatin1String("Invalid unresolved-name")); PARSE_RULE_AND_ADD_RESULT_AS_CHILD(BaseUnresolvedNameNode); } else if (UnresolvedTypeRule::mangledRepresentationStartsWith(PEEK())) { if (m_globalNamespace) - throw ParseException("Invalid unresolved-name"); + throw ParseException(QLatin1String("Invalid unresolved-name")); UnresolvedTypeRule::parse(parseState()); PARSE_RULE_AND_ADD_RESULT_AS_CHILD(BaseUnresolvedNameNode); } else { if (!UnresolvedQualifierLevelRule::mangledRepresentationStartsWith(PEEK())) - throw ParseException("Invalid unresolved-name"); + throw ParseException(QLatin1String("Invalid unresolved-name")); while (UnresolvedQualifierLevelRule::mangledRepresentationStartsWith(PEEK())) UnresolvedQualifierLevelRule::parse(parseState()); if (ADVANCE() != 'E') - throw ParseException("Invalid unresolved-name"); + throw ParseException(QLatin1String("Invalid unresolved-name")); PARSE_RULE_AND_ADD_RESULT_AS_CHILD(BaseUnresolvedNameNode); } } else { @@ -3152,19 +3155,19 @@ void FunctionParamNode::parse() if (NonNegativeNumberNode<10>::mangledRepresentationStartsWith(PEEK())) PARSE_RULE_AND_ADD_RESULT_AS_CHILD(NonNegativeNumberNode<10>); if (ADVANCE() != '_') - throw ParseException("Invalid function-param"); + throw ParseException(QLatin1String("Invalid function-param")); } else if (parseState()->readAhead(2) == "fL") { parseState()->advance(2); PARSE_RULE_AND_ADD_RESULT_AS_CHILD(NonNegativeNumberNode<10>); if (ADVANCE() != 'p') - throw ParseException("Invalid function-param"); + throw ParseException(QLatin1String("Invalid function-param")); PARSE_RULE_AND_ADD_RESULT_AS_CHILD(CvQualifiersNode); if (NonNegativeNumberNode<10>::mangledRepresentationStartsWith(PEEK())) PARSE_RULE_AND_ADD_RESULT_AS_CHILD(NonNegativeNumberNode<10>); if (ADVANCE() != '_') - throw ParseException("Invalid function-param"); + throw ParseException(QLatin1String("Invalid function-param")); } else { - throw ParseException("Invalid function-param"); + throw ParseException(QLatin1String("Invalid function-param")); } } diff --git a/src/plugins/debugger/pdb/pdbengine.cpp b/src/plugins/debugger/pdb/pdbengine.cpp index 58c348e00a3..54672ad2803 100644 --- a/src/plugins/debugger/pdb/pdbengine.cpp +++ b/src/plugins/debugger/pdb/pdbengine.cpp @@ -361,7 +361,7 @@ void PdbEngine::handleBreakInsert(const PdbResponse &response) int pos1 = response.data.indexOf(" at "); QTC_ASSERT(pos1 != -1, return); QByteArray bpnr = response.data.mid(11, pos1 - 11); - int pos2 = response.data.lastIndexOf(":"); + int pos2 = response.data.lastIndexOf(':'); QByteArray file = response.data.mid(pos1 + 4, pos2 - pos1 - 4); QByteArray line = response.data.mid(pos2 + 1); BreakpointResponse br; @@ -630,7 +630,7 @@ void PdbEngine::handleOutput(const QByteArray &data) { //qDebug() << "READ: " << data; m_inbuffer.append(data); - qDebug() << "BUFFER FROM: '" << m_inbuffer << "'"; + qDebug() << "BUFFER FROM: '" << m_inbuffer << '\''; while (true) { int pos = m_inbuffer.indexOf("(Pdb)"); if (pos == -1) @@ -641,7 +641,7 @@ void PdbEngine::handleOutput(const QByteArray &data) m_inbuffer = m_inbuffer.mid(pos + 6); emit outputReady(response); } - qDebug() << "BUFFER LEFT: '" << m_inbuffer << "'"; + qDebug() << "BUFFER LEFT: '" << m_inbuffer << '\''; //m_inbuffer.clear(); } diff --git a/src/plugins/debugger/qml/qmlinspectoradapter.cpp b/src/plugins/debugger/qml/qmlinspectoradapter.cpp index 8a3dd71a1ee..77d24710cd3 100644 --- a/src/plugins/debugger/qml/qmlinspectoradapter.cpp +++ b/src/plugins/debugger/qml/qmlinspectoradapter.cpp @@ -28,6 +28,8 @@ ** **************************************************************************/ +#define QT_NO_CAST_FROM_ASCII + #include "qmlinspectoradapter.h" #include "debuggeractions.h" @@ -117,8 +119,8 @@ QmlInspectorAdapter::QmlInspectorAdapter(QmlAdapter *debugAdapter, this, SLOT(toolsClientStatusChanged(QmlDebug::ClientStatus))); // toolbar - m_selectAction->setObjectName("QML Select Action"); - m_zoomAction->setObjectName("QML Zoom Action"); + m_selectAction->setObjectName(QLatin1String("QML Select Action")); + m_zoomAction->setObjectName(QLatin1String("QML Zoom Action")); m_selectAction->setCheckable(true); m_zoomAction->setCheckable(true); @@ -294,14 +296,14 @@ void QmlInspectorAdapter::createPreviewForEditor(Core::IEditor *newEditor) QmlJS::ModelManagerInterface::instance(); QmlJS::Document::Ptr doc = modelManager->snapshot().document(filename); if (!doc) { - if (filename.endsWith(".qml") || filename.endsWith(".js")) { + if (filename.endsWith(QLatin1String(".qml")) || filename.endsWith(QLatin1String(".js"))) { // add to list of docs that we have to update when // snapshot figures out that there's a new document m_pendingPreviewDocumentNames.append(filename); } return; } - if (!doc->qmlProgram() && !filename.endsWith(".js")) + if (!doc->qmlProgram() && !filename.endsWith(QLatin1String(".js"))) return; QmlJS::Document::Ptr initdoc = m_loadedSnapshot.document(filename); diff --git a/src/plugins/debugger/qml/qmlinspectoragent.cpp b/src/plugins/debugger/qml/qmlinspectoragent.cpp index bed10e28ca0..ab7f926f5cd 100644 --- a/src/plugins/debugger/qml/qmlinspectoragent.cpp +++ b/src/plugins/debugger/qml/qmlinspectoragent.cpp @@ -28,6 +28,8 @@ ** **************************************************************************/ +#define QT_NO_CAST_FROM_ASCII + #include "qmlinspectoragent.h" #include "debuggeractions.h" @@ -73,8 +75,8 @@ quint32 QmlInspectorAgent::queryExpressionResult(int debugId, const QString &expression) { if (debug) - qDebug() << __FUNCTION__ << "(" << debugId << expression - << m_engine.debugId() << ")"; + qDebug() << __FUNCTION__ << '(' << debugId << expression + << m_engine.debugId() << ')'; return m_engineClient->queryExpressionResult(debugId, expression, m_engine.debugId()); @@ -84,7 +86,7 @@ void QmlInspectorAgent::assignValue(const WatchData *data, const QString &expr, const QVariant &valueV) { if (debug) - qDebug() << __FUNCTION__ << "(" << data->id << ")" << data->iname; + qDebug() << __FUNCTION__ << '(' << data->id << ')' << data->iname; if (data->id) { QString val(valueV.toString()); @@ -100,7 +102,7 @@ void QmlInspectorAgent::assignValue(const WatchData *data, void QmlInspectorAgent::updateWatchData(const WatchData &data) { if (debug) - qDebug() << __FUNCTION__ << "(" << data.id << ")"; + qDebug() << __FUNCTION__ << '(' << data.id << ')'; if (data.id && !m_fetchDataIds.contains(data.id)) { // objects @@ -112,7 +114,7 @@ void QmlInspectorAgent::updateWatchData(const WatchData &data) bool QmlInspectorAgent::selectObjectInTree(int debugId) { if (debug) { - qDebug() << __FUNCTION__ << "(" << debugId << ")"; + qDebug() << __FUNCTION__ << '(' << debugId << ')'; qDebug() << " " << debugId << "already fetched? " << m_debugIdToIname.contains(debugId); } @@ -141,8 +143,8 @@ quint32 QmlInspectorAgent::setBindingForObject(int objectDebugId, int line) { if (debug) - qDebug() << __FUNCTION__ << "(" << objectDebugId << propertyName - << value.toString() << isLiteralValue << source << line << ")"; + qDebug() << __FUNCTION__ << '(' << objectDebugId << propertyName + << value.toString() << isLiteralValue << source << line << ')'; if (objectDebugId == -1) return 0; @@ -154,16 +156,16 @@ quint32 QmlInspectorAgent::setBindingForObject(int objectDebugId, || !debuggerCore()->boolSetting(ShowQmlObjectTree)) return 0; - log(LogSend, QString("SET_BINDING %1 %2 %3 %4").arg( + log(LogSend, QString::fromLatin1("SET_BINDING %1 %2 %3 %4").arg( QString::number(objectDebugId), propertyName, value.toString(), - QString(isLiteralValue ? "true" : "false"))); + QString(isLiteralValue ? QLatin1String("true") : QLatin1String("false")))); quint32 queryId = m_engineClient->setBindingForObject( objectDebugId, propertyName, value.toString(), isLiteralValue, source, line); if (!queryId) - log(LogSend, QString("SET_BINDING failed!")); + log(LogSend, QLatin1String("SET_BINDING failed!")); return queryId; } @@ -173,8 +175,8 @@ quint32 QmlInspectorAgent::setMethodBodyForObject(int objectDebugId, const QString &methodBody) { if (debug) - qDebug() << __FUNCTION__ << "(" << objectDebugId - << methodName << methodBody << ")"; + qDebug() << __FUNCTION__ << '(' << objectDebugId + << methodName << methodBody << ')'; if (objectDebugId == -1) return 0; @@ -183,14 +185,14 @@ quint32 QmlInspectorAgent::setMethodBodyForObject(int objectDebugId, || !debuggerCore()->boolSetting(ShowQmlObjectTree)) return 0; - log(LogSend, QString("SET_METHOD_BODY %1 %2 %3").arg( + log(LogSend, QString::fromLatin1("SET_METHOD_BODY %1 %2 %3").arg( QString::number(objectDebugId), methodName, methodBody)); quint32 queryId = m_engineClient->setMethodBody( objectDebugId, methodName, methodBody); if (!queryId) - log(LogSend, QString("failed!")); + log(LogSend, QLatin1String("failed!")); return queryId; } @@ -199,8 +201,8 @@ quint32 QmlInspectorAgent::resetBindingForObject(int objectDebugId, const QString &propertyName) { if (debug) - qDebug() << __FUNCTION__ << "(" << objectDebugId - << propertyName << ")"; + qDebug() << __FUNCTION__ << '(' << objectDebugId + << propertyName << ')'; if (objectDebugId == -1) return 0; @@ -209,14 +211,14 @@ quint32 QmlInspectorAgent::resetBindingForObject(int objectDebugId, || !debuggerCore()->boolSetting(ShowQmlObjectTree)) return 0; - log(LogSend, QString("RESET_BINDING %1 %2").arg( + log(LogSend, QString::fromLatin1("RESET_BINDING %1 %2").arg( QString::number(objectDebugId), propertyName)); quint32 queryId = m_engineClient->resetBindingForObject( objectDebugId, propertyName); if (!queryId) - log(LogSend, QString("failed!")); + log(LogSend, QLatin1String("failed!")); return queryId; } @@ -291,7 +293,7 @@ QHash<int,QString> QmlInspectorAgent::rootObjectIds() const if (!data) continue; int debugId = data->id; - QString className = data->type; + QString className = QLatin1String(data->type); rIds.insert(debugId, className); } return rIds; @@ -300,7 +302,7 @@ QHash<int,QString> QmlInspectorAgent::rootObjectIds() const bool QmlInspectorAgent::addObjectWatch(int objectDebugId) { if (debug) - qDebug() << __FUNCTION__ << "(" << objectDebugId << ")"; + qDebug() << __FUNCTION__ << '(' << objectDebugId << ')'; if (objectDebugId == -1) return false; @@ -330,7 +332,7 @@ bool QmlInspectorAgent::isObjectBeingWatched(int objectDebugId) bool QmlInspectorAgent::removeObjectWatch(int objectDebugId) { if (debug) - qDebug() << __FUNCTION__ << "(" << objectDebugId << ")"; + qDebug() << __FUNCTION__ << '(' << objectDebugId << ')'; if (objectDebugId == -1) return false; @@ -418,14 +420,14 @@ void QmlInspectorAgent::onResult(quint32 queryId, const QVariant &value, if (debug) qDebug() << __FUNCTION__ << "() ..."; - if (type == _("FETCH_OBJECT_R")) { + if (type == "FETCH_OBJECT_R") { log(LogReceive, _("FETCH_OBJECT_R %1").arg( qvariant_cast<ObjectReference>(value).idString())); - } else if (type == _("SET_BINDING_R") - || type == _("RESET_BINDING_R") - || type == _("SET_METHOD_BODY_R")) { + } else if (type == "SET_BINDING_R" + || type == "RESET_BINDING_R" + || type == "SET_METHOD_BODY_R") { QString msg = QLatin1String(type) + tr(" success : "); - msg += value.toBool() ? "1" : "0"; + msg += value.toBool() ? QLatin1Char('1') : QLatin1Char('0'); if (!value.toBool()) emit automaticUpdateFailed(); log(LogReceive, msg); @@ -470,13 +472,13 @@ void QmlInspectorAgent::newObject(int engineId, int objectId, int /*parentId*/) if (debug) qDebug() << __FUNCTION__ << "()"; - log(LogReceive, QString("OBJECT_CREATED")); + log(LogReceive, QLatin1String("OBJECT_CREATED")); if (m_engine.debugId() != engineId) return; m_newObjectsCreated = true; - if (m_engineClient->objectName() == QmlDebug::Constants::QML_DEBUGGER) + if (m_engineClient->objectName() == QLatin1String(QmlDebug::Constants::QML_DEBUGGER)) fetchObject(objectId); else m_delayQueryTimer.start(); @@ -490,7 +492,7 @@ void QmlInspectorAgent::onValueChanged(int debugId, const QByteArray &propertyNa WatchHandler *watchHandler = m_debuggerEngine->watchHandler(); const WatchData *data = watchHandler->findData(iname); if (debug) - qDebug() << __FUNCTION__ << "(" << debugId << ")" << iname <<value.toString(); + qDebug() << __FUNCTION__ << '(' << debugId << ')' << iname << value.toString(); if (data) { WatchData d(*data); d.value = value.toString(); @@ -536,7 +538,7 @@ void QmlInspectorAgent::queryEngineContext() || !debuggerCore()->boolSetting(ShowQmlObjectTree)) return; - log(LogSend, QString("LIST_OBJECTS")); + log(LogSend, QLatin1String("LIST_OBJECTS")); m_rootContextQueryId = m_engineClient->queryRootContexts(m_engine); @@ -545,16 +547,16 @@ void QmlInspectorAgent::queryEngineContext() void QmlInspectorAgent::fetchObject(int debugId) { if (debug) - qDebug() << __FUNCTION__ << "(" << debugId << ")"; + qDebug() << __FUNCTION__ << '(' << debugId << ')'; if (!isConnected() || !debuggerCore()->boolSetting(ShowQmlObjectTree)) return; - log(LogSend, QString("FETCH_OBJECT %1").arg(QString::number(debugId))); + log(LogSend, QLatin1String("FETCH_OBJECT ") + QString::number(debugId)); quint32 queryId = m_engineClient->queryObject(debugId); if (debug) - qDebug() << __FUNCTION__ << "(" << debugId << ")" + qDebug() << __FUNCTION__ << '(' << debugId << ')' << " - query id" << queryId; m_objectTreeQueryIds << queryId; } @@ -565,20 +567,20 @@ void QmlInspectorAgent::fetchContextObjectsForLocation(const QString &file, // This can be an expensive operation as it may return multiple // objects. Use fetchContextObject() where possible. if (debug) - qDebug() << __FUNCTION__ << "(" << file << ":" << lineNumber - << ":" << columnNumber << ")"; + qDebug() << __FUNCTION__ << '(' << file << ':' << lineNumber + << ':' << columnNumber << ')'; if (!isConnected() || !debuggerCore()->boolSetting(ShowQmlObjectTree)) return; - log(LogSend, QString("FETCH_OBJECTS_FOR_LOCATION %1:%2:%3").arg(file) + log(LogSend, QString::fromLatin1("FETCH_OBJECTS_FOR_LOCATION %1:%2:%3").arg(file) .arg(QString::number(lineNumber)).arg(QString::number(columnNumber))); quint32 queryId = m_engineClient->queryObjectsForLocation(QFileInfo(file).fileName(), lineNumber, columnNumber); if (debug) - qDebug() << __FUNCTION__ << "(" << file << ":" << lineNumber - << ":" << columnNumber << ")" << " - query id" << queryId; + qDebug() << __FUNCTION__ << '(' << file << ':' << lineNumber + << ':' << columnNumber << ')' << " - query id" << queryId; m_objectTreeQueryIds << queryId; } @@ -587,7 +589,7 @@ void QmlInspectorAgent::fetchContextObjectsForLocation(const QString &file, void QmlInspectorAgent::fetchObjectsInContextRecursive(const ContextReference &context) { if (debug) - qDebug() << __FUNCTION__ << "(" << context << ")"; + qDebug() << __FUNCTION__ << '(' << context << ')'; if (!isConnected() || !debuggerCore()->boolSetting(ShowQmlObjectTree)) @@ -595,7 +597,7 @@ void QmlInspectorAgent::fetchObjectsInContextRecursive(const ContextReference &c foreach (const ObjectReference & obj, context.objects()) { using namespace QmlDebug::Constants; - if (m_engineClient->objectName() == QML_DEBUGGER && + if (m_engineClient->objectName() == QLatin1String(QML_DEBUGGER) && m_engineClient->serviceVersion() >= CURRENT_SUPPORTED_VERSION) { //Fetch only root objects if (obj.parentId() == -1) @@ -611,7 +613,7 @@ void QmlInspectorAgent::fetchObjectsInContextRecursive(const ContextReference &c void QmlInspectorAgent::objectTreeFetched(const ObjectReference &object) { if (debug) - qDebug() << __FUNCTION__ << "(" << object << ")"; + qDebug() << __FUNCTION__ << '(' << object << ')'; if (!object.isValid()) return; @@ -629,7 +631,7 @@ void QmlInspectorAgent::objectTreeFetched(const ObjectReference &object) QStack<QmlDebug::ObjectReference> stack; // 4.x - if (m_newObjectsCreated && m_engineClient->objectName() != QmlDebug::Constants::QML_DEBUGGER) { + if (m_newObjectsCreated && m_engineClient->objectName() != QLatin1String(QmlDebug::Constants::QML_DEBUGGER)) { // We need to reverse the stack as the root objects // are pushed to the bottom since they are fetched first. // The child objects need to placed in the correct position and therefore @@ -646,7 +648,7 @@ void QmlInspectorAgent::objectTreeFetched(const ObjectReference &object) QByteArray parentIname; // 4.x - if (m_engineClient->objectName() != QmlDebug::Constants::QML_DEBUGGER) { + if (m_engineClient->objectName() != QLatin1String(QmlDebug::Constants::QML_DEBUGGER)) { QHashIterator<int, QList<int> > i(m_debugIdChildIds); while (i.hasNext()) { i.next(); @@ -663,7 +665,7 @@ void QmlInspectorAgent::objectTreeFetched(const ObjectReference &object) return; } // 5.x - if (m_engineClient->objectName() == QmlDebug::Constants::QML_DEBUGGER + if (m_engineClient->objectName() == QLatin1String(QmlDebug::Constants::QML_DEBUGGER) && m_newObjectsCreated && parentIname.isEmpty()) { if (watchData.count()) break; @@ -709,7 +711,7 @@ void QmlInspectorAgent::objectTreeFetched(const ObjectReference &object) void QmlInspectorAgent::buildDebugIdHashRecursive(const ObjectReference &ref) { if (debug) - qDebug() << __FUNCTION__ << "(" << ref << ")"; + qDebug() << __FUNCTION__ << '(' << ref << ')'; QUrl fileUrl = ref.source().url(); int lineNum = ref.source().lineNumber(); @@ -718,7 +720,7 @@ void QmlInspectorAgent::buildDebugIdHashRecursive(const ObjectReference &ref) // handle the case where the url contains the revision number encoded. //(for object created by the debugger) - static QRegExp rx("(.*)_(\\d+):(\\d+)$"); + static QRegExp rx(QLatin1String("(.*)_(\\d+):(\\d+)$")); if (rx.exactMatch(fileUrl.path())) { fileUrl.setPath(rx.cap(1)); rev = rx.cap(2).toInt(); @@ -736,7 +738,7 @@ void QmlInspectorAgent::buildDebugIdHashRecursive(const ObjectReference &ref) m_debugIdLocations.insert(ref.debugId(), FileReference(filePath, lineNum, colNum)); // 4.x - if (m_newObjectsCreated && m_engineClient->objectName() != QmlDebug::Constants::QML_DEBUGGER) { + if (m_newObjectsCreated && m_engineClient->objectName() != QLatin1String(QmlDebug::Constants::QML_DEBUGGER)) { QList<int> childIds; foreach (const ObjectReference &c, ref.children()) { childIds << c.debugId(); @@ -767,7 +769,7 @@ QList<WatchData> QmlInspectorAgent::buildWatchData(const ObjectReference &obj, bool append) { if (debug) - qDebug() << __FUNCTION__ << "(" << obj << parentIname << ")"; + qDebug() << __FUNCTION__ << '(' << obj << parentIname << ')'; QList<WatchData> list; @@ -878,7 +880,7 @@ void QmlInspectorAgent::clearObjectTree() m_debugIdChildIds.clear(); m_objectStack.clear(); // reset only for 5.x. - if (m_engineClient->objectName() == QmlDebug::Constants::QML_DEBUGGER) + if (m_engineClient->objectName() == QLatin1String(QmlDebug::Constants::QML_DEBUGGER)) m_newObjectsCreated = false; removeAllObjectWatches(); diff --git a/src/plugins/debugger/qml/qmllivetextpreview.cpp b/src/plugins/debugger/qml/qmllivetextpreview.cpp index 5d69246262a..05e8ac4938c 100644 --- a/src/plugins/debugger/qml/qmllivetextpreview.cpp +++ b/src/plugins/debugger/qml/qmllivetextpreview.cpp @@ -28,6 +28,8 @@ ** **************************************************************************/ +#define QT_NO_CAST_FROM_ASCII + #include "qmllivetextpreview.h" #include "qmlinspectoradapter.h" @@ -602,7 +604,7 @@ void QmlLiveTextPreview::documentChanged(QmlJS::Document::Ptr doc) m_docWithUnappliedChanges.clear(); if (doc && m_previousDoc && doc->fileName() == m_previousDoc->fileName()) { - if (doc->fileName().endsWith(".js")) { + if (doc->fileName().endsWith(QLatin1String(".js"))) { showSyncWarning(JSChangeWarning, QString(), 0, 0); m_previousDoc = doc; return; @@ -715,7 +717,7 @@ void QmlLiveTextPreview::showSyncWarning( foreach (TextEditor::BaseTextEditorWidget *editor, m_editors) { if (editor) { Core::InfoBar *infoBar = editor->editorDocument()->infoBar(); - Core::InfoBarEntry info(INFO_OUT_OF_SYNC, errorMessage); + Core::InfoBarEntry info(QLatin1String(INFO_OUT_OF_SYNC), errorMessage); BaseToolsClient *toolsClient = m_inspectorAdapter->toolsClient(); if (toolsClient && toolsClient->supportReload()) info.setCustomButtonInfo(tr("Reload QML"), this, @@ -736,7 +738,7 @@ void QmlLiveTextPreview::removeOutofSyncInfo() foreach (TextEditor::BaseTextEditorWidget *editor, m_editors) { if (editor) { Core::InfoBar *infoBar = editor->editorDocument()->infoBar(); - infoBar->removeInfo(INFO_OUT_OF_SYNC); + infoBar->removeInfo(QLatin1String(INFO_OUT_OF_SYNC)); } } } diff --git a/src/plugins/debugger/qml/qmlv8debuggerclient.cpp b/src/plugins/debugger/qml/qmlv8debuggerclient.cpp index c6294ded9fd..ed9ac64c57e 100644 --- a/src/plugins/debugger/qml/qmlv8debuggerclient.cpp +++ b/src/plugins/debugger/qml/qmlv8debuggerclient.cpp @@ -28,6 +28,8 @@ ** **************************************************************************/ +#define QT_NO_CAST_FROM_ASCII + #include "qmlv8debuggerclient.h" #include "qmlv8debuggerclientconstants.h" #include "debuggerstringutils.h" @@ -1409,7 +1411,7 @@ void QmlV8DebuggerClient::messageReceived(const QByteArray &data) const QVariantMap breakData = resp.value(_(BODY)).toMap(); const QString invocationText = breakData.value(_("invocationText")).toString(); const QString scriptUrl = breakData.value(_("script")).toMap().value(_("name")).toString(); - const QString sourceLineText = breakData.value("sourceLineText").toString(); + const QString sourceLineText = breakData.value(_("sourceLineText")).toString(); bool inferiorStop = true; @@ -1448,7 +1450,7 @@ void QmlV8DebuggerClient::messageReceived(const QByteArray &data) params.enabled, params.lineNumber, newColumn, - QString(params.condition), + QString(QString::fromLatin1(params.condition)), params.ignoreCount); d->breakpointsSync.insert(d->sequence, internalId); } @@ -1627,7 +1629,7 @@ StackFrame QmlV8DebuggerClient::extractStackFrame(const QVariant &bodyVal, const StackFrame stackFrame; stackFrame.level = body.value(_("index")).toInt(); //Do not insert the frame corresponding to the internal function - if (body.value("sourceLineText").toByteArray() == INTERNAL_FUNCTION) { + if (body.value(QLatin1String("sourceLineText")) == QLatin1String(INTERNAL_FUNCTION)) { stackFrame.level = -1; return stackFrame; } @@ -1827,7 +1829,7 @@ void QmlV8DebuggerClient::updateEvaluationResult(int sequence, bool success, con QList<WatchData> watchDataList; WatchData data; //Do we have request to evaluate a local? - if (exp.startsWith("local.")) { + if (exp.startsWith(QLatin1String("local."))) { const WatchData *watch = watchHandler->findData(exp.toLatin1()); watchDataList << createWatchDataList(watch, body.properties, refsVal); } else { @@ -1959,7 +1961,7 @@ QList<WatchData> QmlV8DebuggerClient::createWatchDataList(const WatchData *paren foreach (const QVariant &property, properties) { QmlV8ObjectData propertyData = d->extractData(property, refsVal); WatchData data; - data.name = propertyData.name; + data.name = QString::fromUtf8(propertyData.name); //Check for v8 specific local data if (data.name.startsWith(QLatin1Char('.')) || data.name.isEmpty()) diff --git a/src/plugins/debugger/snapshothandler.cpp b/src/plugins/debugger/snapshothandler.cpp index 300fd8109f5..3e4a9671de8 100644 --- a/src/plugins/debugger/snapshothandler.cpp +++ b/src/plugins/debugger/snapshothandler.cpp @@ -62,7 +62,7 @@ QString SnapshotData::function() const if (m_frames.isEmpty()) return QString(); const StackFrame &frame = m_frames.at(0); - return frame.function + ":" + QString::number(frame.line); + return frame.function + QLatin1Char(':') + QString::number(frame.line); } QString SnapshotData::toString() const diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 1805d6e5898..4d57dc478bc 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -28,6 +28,8 @@ ** **************************************************************************/ +#define QT_NO_CAST_FROM_ASCII + #include "watchhandler.h" #include "breakhandler.h" @@ -1413,7 +1415,7 @@ void WatchModel::showInEditorHelper(QString *contents, WatchItem *item, int dept contents->append(tab); contents->append(item->value); contents->append(tab); - contents->append(item->type); + contents->append(QString::fromLatin1(item->type)); contents->append(nl); foreach (WatchItem *child, item->children) showInEditorHelper(contents, child, depth + 1); -- GitLab