diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2011-12-21 14:02:52 +0100 |
---|---|---|
committer | hjk <qthjk@ovi.com> | 2011-12-21 14:07:12 +0100 |
commit | a92e38f47f7c54a0844e98e47d3a0f830b1c4c93 (patch) | |
tree | 31293326939661f77c3ba4b816fef109378afbb2 /src/plugins/debugger | |
parent | ec4939005269cb62809668f89559e2dc582d8b38 (diff) | |
download | qt-creator-a92e38f47f7c54a0844e98e47d3a0f830b1c4c93.tar.gz |
Debugger: Compile with QT_NO_CAST_FROM_ASCII.
(except gdbmi.cpp, name_demangler.cpp). Remove some unneeded
conversions, change some maps to take QByteArray keys.
Change-Id: I010f1251998a441fe5c8c87901b1e0c277c0391c
Reviewed-by: hjk <qthjk@ovi.com>
Diffstat (limited to 'src/plugins/debugger')
38 files changed, 327 insertions, 328 deletions
diff --git a/src/plugins/debugger/breakhandler.cpp b/src/plugins/debugger/breakhandler.cpp index 1de7273df1..2149de4469 100644 --- a/src/plugins/debugger/breakhandler.cpp +++ b/src/plugins/debugger/breakhandler.cpp @@ -337,7 +337,7 @@ void BreakHandler::saveBreakpoints() map.insert(_("message"), data.message); list.append(map); } - debuggerCore()->setSessionValue("Breakpoints", list); + debuggerCore()->setSessionValue(QLatin1String("Breakpoints"), list); //qDebug() << "SAVED BREAKPOINTS" << this << list.size(); } @@ -345,7 +345,7 @@ void BreakHandler::loadBreakpoints() { QTC_ASSERT(debuggerCore(), return); //qDebug() << "LOADING BREAKPOINTS..."; - QVariant value = debuggerCore()->sessionValue("Breakpoints"); + QVariant value = debuggerCore()->sessionValue(QLatin1String("Breakpoints")); QList<QVariant> list = value.toList(); //clear(); foreach (const QVariant &var, list) { diff --git a/src/plugins/debugger/breakpoint.cpp b/src/plugins/debugger/breakpoint.cpp index 5ecd5810a8..f81a507987 100644 --- a/src/plugins/debugger/breakpoint.cpp +++ b/src/plugins/debugger/breakpoint.cpp @@ -79,9 +79,9 @@ QByteArray BreakpointModelId::toByteArray() const QString BreakpointModelId::toString() const { if (!isValid()) - return "<invalid bkpt>"; + return QLatin1String("<invalid bkpt>"); if (isMinor()) - return QString("%1.%2").arg(m_majorPart).arg(m_minorPart); + return QString::fromLatin1("%1.%2").arg(m_majorPart).arg(m_minorPart); return QString::number(m_majorPart); } @@ -148,9 +148,9 @@ QByteArray BreakpointResponseId::toByteArray() const QString BreakpointResponseId::toString() const { if (!isValid()) - return "<invalid bkpt>"; + return QLatin1String("<invalid bkpt>"); if (isMinor()) - return QString("%1.%2").arg(m_majorPart).arg(m_minorPart); + return QString::fromLatin1("%1.%2").arg(m_majorPart).arg(m_minorPart); return QString::number(m_majorPart); } diff --git a/src/plugins/debugger/breakwindow.cpp b/src/plugins/debugger/breakwindow.cpp index 77a983e22c..c4618a94c0 100644 --- a/src/plugins/debugger/breakwindow.cpp +++ b/src/plugins/debugger/breakwindow.cpp @@ -276,7 +276,7 @@ void BreakpointDialog::getParts(unsigned partsMask, BreakpointParameters *data) if (partsMask & AddressPart) data->address = m_ui.lineEditAddress->text().toULongLong(0, 0); if (partsMask & ExpressionPart) - data->expression = m_ui.lineEditExpression->text().toUtf8(); + data->expression = m_ui.lineEditExpression->text(); if (partsMask & ConditionPart) data->condition = m_ui.lineEditCondition->text().toUtf8(); diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index 718443bfc2..be008baf52 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -1049,7 +1049,7 @@ void CdbEngine::handleAddWatch(const CdbExtensionCommandPtr &reply) watchHandler()->insertData(item); showMessage(QString::fromLatin1("Unable to add watch item '%1'/'%2': %3"). arg(QString::fromAscii(item.iname), QString::fromAscii(item.exp), - reply->errorMessage), LogError); + QString::fromLocal8Bit(reply->errorMessage)), LogError); } } @@ -1263,12 +1263,14 @@ void CdbEngine::handleJumpToLineAddressResolution(const CdbBuiltinCommandPtr &cm return; // Evaluate expression: 5365511549 = 00000001`3fcf357d // Set register 'rip' to hex address and goto lcoation - QString answer = QString::fromAscii(cmd->reply.front()).trimmed(); + QByteArray answer = cmd->reply.front().trimmed(); const int equalPos = answer.indexOf(" = "); if (equalPos == -1) return; answer.remove(0, equalPos + 3); - answer.remove(QLatin1Char('`')); + const int apPos = answer.indexOf('`'); + if (apPos != -1) + answer.remove(apPos, 1); bool ok; const quint64 address = answer.toLongLong(&ok, 16); if (ok && address) { @@ -2844,7 +2846,7 @@ void CdbEngine::handleStackTrace(const CdbExtensionCommandPtr &command) parseStackTrace(data, false); postCommandSequence(command->commandSequence); } else { - showMessage(command->errorMessage, LogError); + showMessage(QString::fromLocal8Bit(command->errorMessage), LogError); } } @@ -2854,7 +2856,7 @@ void CdbEngine::handleExpression(const CdbExtensionCommandPtr &command) if (command->success) { value = command->reply.toInt(); } else { - showMessage(command->errorMessage, LogError); + showMessage(QString::fromLocal8Bit(command->errorMessage), LogError); } // Is this a conditional breakpoint? if (command->cookie.isValid() && qVariantCanConvert<ConditionalBreakPointCookie>(command->cookie)) { diff --git a/src/plugins/debugger/consolewindow.cpp b/src/plugins/debugger/consolewindow.cpp index 80f5ba887f..593503c0de 100644 --- a/src/plugins/debugger/consolewindow.cpp +++ b/src/plugins/debugger/consolewindow.cpp @@ -54,36 +54,6 @@ namespace Debugger { namespace Internal { -static QChar charForChannel(int channel) -{ - switch (channel) { - case LogDebug: return 'd'; - case LogWarning: return 'w'; - case LogError: return 'e'; - case LogInput: return '<'; - case LogOutput: return '>'; - case LogStatus: return 's'; - case LogTime: return 't'; - case LogMisc: - default: return ' '; - } -} - -static int channelForChar(QChar c) -{ - switch (c.unicode()) { - case 'd': return LogDebug; - case 'w': return LogWarning; - case 'e': return LogError; - case '<': return LogInput; - case '>': return LogOutput; - case 's': return LogStatus; - case 't': return LogTime; - default: return LogMisc; - } -} - - ///////////////////////////////////////////////////////////////////// // // ConsoleHighlighter @@ -101,7 +71,7 @@ private: void highlightBlock(const QString &text) { QTextCharFormat format; - switch (channelForChar(text.isEmpty() ? QChar() : text.at(0))) { + switch (LogWindow::channelForChar(text.isEmpty() ? QChar() : text.at(0))) { case LogInput: format.setForeground(Qt::blue); setFormat(1, text.size(), format); @@ -235,7 +205,7 @@ public: int n = 0; // cut time string - if (line.size() > 18 && line.at(0) == '[') + if (line.size() > 18 && line.at(0) == QLatin1Char('[')) line = line.mid(18); //qDebug() << line; @@ -273,7 +243,7 @@ ConsoleWindow::ConsoleWindow(QWidget *parent) : QWidget(parent) { setWindowTitle(tr("Console")); - setObjectName("Console"); + setObjectName(QLatin1String("Console")); m_console = new Console(this); m_console->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); @@ -302,14 +272,14 @@ void ConsoleWindow::showOutput(int channel, const QString &output) //cursor.movePosition(QTextCursor::End); //bool atEnd = oldCursor.position() == cursor.position(); - foreach (QString line, output.split('\n')) { + foreach (QString line, output.split(QLatin1Char('\n'))) { // FIXME: QTextEdit asserts on really long lines... const int n = 30000; if (line.size() > n) { line.truncate(n); line += QLatin1String(" [...] <cut off>"); } - m_console->appendPlainText(charForChannel(channel) + line + '\n'); + m_console->appendPlainText(LogWindow::charForChannel(channel) + line + QLatin1Char('\n')); } QTextCursor cursor = m_console->textCursor(); cursor.movePosition(QTextCursor::End); diff --git a/src/plugins/debugger/debuggerdialogs.cpp b/src/plugins/debugger/debuggerdialogs.cpp index c77d63e23d..11af2bcf7e 100644 --- a/src/plugins/debugger/debuggerdialogs.cpp +++ b/src/plugins/debugger/debuggerdialogs.cpp @@ -1063,7 +1063,7 @@ void TypeFormatsDialog::addTypeFormats(const QString &type0, const QStringList &typeFormats, int current) { QString type = type0; - type.replace("__", "::"); + type.replace(QLatin1String("__"), QLatin1String("::")); int pos = 2; if (type.startsWith(QLatin1Char('Q'))) pos = 0; diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index 9843aa0ec9..a3c3b055f9 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -612,7 +612,7 @@ void DebuggerEngine::gotoLocation(const Location &loc) // Called from RunControl. void DebuggerEngine::handleStartFailed() { - showMessage("HANDLE RUNCONTROL START FAILED"); + showMessage(QLatin1String("HANDLE RUNCONTROL START FAILED")); d->m_runControl = 0; d->m_progress.setProgressValue(900); d->m_progress.reportCanceled(); @@ -622,7 +622,7 @@ void DebuggerEngine::handleStartFailed() // Called from RunControl. void DebuggerEngine::handleFinished() { - showMessage("HANDLE RUNCONTROL FINISHED"); + showMessage(QLatin1String("HANDLE RUNCONTROL FINISHED")); d->m_runControl = 0; d->m_progress.setProgressValue(1000); d->m_progress.reportFinished(); @@ -1094,20 +1094,30 @@ void DebuggerEngine::slaveEngineStateChanged(DebuggerEngine *slaveEngine, Q_UNUSED(state); } +static inline QString msgStateChanged(DebuggerState oldState, DebuggerState newState, + bool forced, bool master) +{ + QString result; + QTextStream str(&result); + str << "State changed"; + if (forced) + str << " BY FORCE"; + str << " from " << DebuggerEngine::stateName(oldState) << '(' << oldState + << ") to " << DebuggerEngine::stateName(newState) << '(' << newState << ')'; + if (master) + str << " [master]"; + return result; +} + void DebuggerEngine::setState(DebuggerState state, bool forced) { - if (isStateDebugging()) { - qDebug() << "STATUS CHANGE: " << this - << " FROM " << stateName(d->m_state) << " TO " << stateName(state) - << isMasterEngine(); - } + const QString msg = msgStateChanged(d->m_state, state, forced, isMasterEngine()); + if (isStateDebugging()) + qDebug("%s", qPrintable(msg)); DebuggerState oldState = d->m_state; d->m_state = state; - QString msg = _("State changed%5 from %1(%2) to %3(%4).") - .arg(stateName(oldState)).arg(oldState).arg(stateName(state)).arg(state) - .arg(forced ? " BY FORCE" : ""); if (!forced && !isAllowedTransition(oldState, state)) qDebug() << "*** UNEXPECTED STATE TRANSITION: " << this << msg; @@ -1727,7 +1737,7 @@ void DebuggerEnginePrivate::handleAutoTestLine(int line) QString name = s.section(QLatin1Char(' '), 1, 1); if (name.isEmpty()) { reportTestError(_("'Check' needs arguments."), line); - } else if (name.contains(QChar('.'))) { + } else if (name.contains(QLatin1Char('.'))) { m_engine->showMessage(_("variable %1 found in line %2 contains '.', but 'Expand' is not implemented yet.").arg(name).arg(line)); } else { QByteArray iname = "local." + name.toLatin1(); @@ -1751,7 +1761,7 @@ void DebuggerEnginePrivate::handleAutoTestLine(int line) QString name = s.section(QLatin1Char(' '), 1, 1); if (name.isEmpty()) { reportTestError(_("'CheckType' needs arguments."), line); - } else if (name.contains(QChar('.'))) { + } else if (name.contains(QLatin1Char('.'))) { m_engine->showMessage(_("variable %1 found in line %2 contains '.', but 'Expand' is not implemented yet.").arg(name).arg(line)); } else { QByteArray iname = "local." + name.toLatin1(); diff --git a/src/plugins/debugger/debuggermainwindow.cpp b/src/plugins/debugger/debuggermainwindow.cpp index d43f8c7967..f3bc617d10 100644 --- a/src/plugins/debugger/debuggermainwindow.cpp +++ b/src/plugins/debugger/debuggermainwindow.cpp @@ -286,7 +286,7 @@ void DebuggerMainWindow::setEngineDebugLanguages(DebuggerLanguages languages) void DebuggerMainWindow::onModeChanged(IMode *mode) { - d->m_inDebugMode = (mode && mode->id() == Constants::MODE_DEBUG); + d->m_inDebugMode = (mode && mode->id() == QLatin1String(Constants::MODE_DEBUG)); setDockActionsVisible(d->m_inDebugMode); // Hide all the debugger windows if mode is different. @@ -427,7 +427,7 @@ QDockWidget *DebuggerMainWindow::createDockWidget(const DebuggerLanguage &langua ActionManager *am = ICore::instance()->actionManager(); QAction *toggleViewAction = dockWidget->toggleViewAction(); Command *cmd = am->registerAction(toggleViewAction, - Core::Id("Debugger." + widget->objectName()), globalContext); + Core::Id(QLatin1String("Debugger.") + widget->objectName()), globalContext); cmd->setAttribute(Command::CA_Hide); d->m_viewsMenu->addAction(cmd); @@ -646,17 +646,17 @@ void DebuggerMainWindowPrivate::setSimpleDockWidgetArrangement() } QDockWidget *toolBarDock = q->toolBarDockWidget(); - QDockWidget *breakDock = q->dockWidget(DOCKWIDGET_BREAK); - QDockWidget *stackDock = q->dockWidget(DOCKWIDGET_STACK); - QDockWidget *watchDock = q->dockWidget(DOCKWIDGET_WATCHERS); - QDockWidget *snapshotsDock = q->dockWidget(DOCKWIDGET_SNAPSHOTS); - QDockWidget *threadsDock = q->dockWidget(DOCKWIDGET_THREADS); - QDockWidget *outputDock = q->dockWidget(DOCKWIDGET_OUTPUT); - QDockWidget *qmlInspectorDock = q->dockWidget(DOCKWIDGET_QML_INSPECTOR); - QDockWidget *scriptConsoleDock = q->dockWidget(DOCKWIDGET_QML_SCRIPTCONSOLE); - QDockWidget *modulesDock = q->dockWidget(DOCKWIDGET_MODULES); - QDockWidget *registerDock = q->dockWidget(DOCKWIDGET_REGISTER); - QDockWidget *sourceFilesDock = q->dockWidget(DOCKWIDGET_SOURCE_FILES); + QDockWidget *breakDock = q->dockWidget(QLatin1String(DOCKWIDGET_BREAK)); + QDockWidget *stackDock = q->dockWidget(QLatin1String(DOCKWIDGET_STACK)); + QDockWidget *watchDock = q->dockWidget(QLatin1String(DOCKWIDGET_WATCHERS)); + QDockWidget *snapshotsDock = q->dockWidget(QLatin1String(DOCKWIDGET_SNAPSHOTS)); + QDockWidget *threadsDock = q->dockWidget(QLatin1String(DOCKWIDGET_THREADS)); + QDockWidget *outputDock = q->dockWidget(QLatin1String(DOCKWIDGET_OUTPUT)); + QDockWidget *qmlInspectorDock = q->dockWidget(QLatin1String(DOCKWIDGET_QML_INSPECTOR)); + QDockWidget *scriptConsoleDock = q->dockWidget(QLatin1String(DOCKWIDGET_QML_SCRIPTCONSOLE)); + QDockWidget *modulesDock = q->dockWidget(QLatin1String(DOCKWIDGET_MODULES)); + QDockWidget *registerDock = q->dockWidget(QLatin1String(DOCKWIDGET_REGISTER)); + QDockWidget *sourceFilesDock = q->dockWidget(QLatin1String(DOCKWIDGET_SOURCE_FILES)); QTC_ASSERT(breakDock, return); QTC_ASSERT(stackDock, return); diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 92911d78a9..0655d706fa 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -506,8 +506,8 @@ public: setDisplayName(DebuggerPlugin::tr("Debug")); setIcon(QIcon(QLatin1String(":/fancyactionbar/images/mode_Debug.png"))); setPriority(85); - setId(MODE_DEBUG); - setType(CC::MODE_EDIT_TYPE); + setId(QLatin1String(MODE_DEBUG)); + setType(QLatin1String(CC::MODE_EDIT_TYPE)); } ~DebugMode() @@ -697,7 +697,7 @@ public slots: void synchronizeBreakpoints() { - showMessage("ATTEMPT SYNC", LogDebug); + showMessage(QLatin1String("ATTEMPT SYNC"), LogDebug); for (int i = 0, n = m_snapshotHandler->size(); i != n; ++i) { if (DebuggerEngine *engine = m_snapshotHandler->at(i)) engine->attemptBreakpointSynchronization(); @@ -899,7 +899,7 @@ public slots: if (functionName.isEmpty()) { const QTextBlock block = cursor.block(); const QString line = block.text(); - foreach (const QString &str, line.trimmed().split('(')) { + foreach (const QString &str, line.trimmed().split(QLatin1Char('('))) { QString a; for (int i = str.size(); --i >= 0; ) { if (!str.at(i).isLetterOrNumber()) @@ -1127,7 +1127,7 @@ DebuggerPluginPrivate::DebuggerPluginPrivate(DebuggerPlugin *plugin) : m_dummyEngine(0), m_globalDebuggerOptions(new GlobalDebuggerOptions) { - setObjectName("DebuggerCore"); + setObjectName(QLatin1String("DebuggerCore")); qRegisterMetaType<WatchData>("WatchData"); qRegisterMetaType<ContextData>("ContextData"); qRegisterMetaType<DebuggerStartParameters>("DebuggerStartParameters"); @@ -1228,15 +1228,16 @@ void DebuggerPluginPrivate::maybeEnrichParameters(DebuggerStartParameters *sp) showMessage(QString::fromLatin1("USING QTC_DEBUGGER_SYSROOT %1") .arg(sp->sysroot), LogWarning); } - if (sp->debugInfoLocation.isEmpty()) - sp->debugInfoLocation = sp->sysroot + "/usr/lib/debug"; + if (sp->debugInfoLocation.isEmpty()) { + sp->debugInfoLocation = sp->sysroot + QLatin1String("/usr/lib/debug"); + } if (sp->debugSourceLocation.isEmpty()) { - QString base = sp->sysroot + "/usr/src/debug/"; - sp->debugSourceLocation.append(base + "qt5base/src/corelib"); - sp->debugSourceLocation.append(base + "qt5base/src/gui"); - sp->debugSourceLocation.append(base + "qt5base/src/network"); - sp->debugSourceLocation.append(base + "qt5base/src/v8"); - sp->debugSourceLocation.append(base + "qt5declarative/src/declarative/qml"); + QString base = sp->sysroot + QLatin1String("/usr/src/debug/"); + sp->debugSourceLocation.append(base + QLatin1String("qt5base/src/corelib")); + sp->debugSourceLocation.append(base + QLatin1String("qt5base/src/gui")); + sp->debugSourceLocation.append(base + QLatin1String("qt5base/src/network")); + sp->debugSourceLocation.append(base + QLatin1String("qt5base/src/v8")); + sp->debugSourceLocation.append(base + QLatin1String("qt5declarative/src/declarative/qml")); } } @@ -1256,7 +1257,8 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it, } DebuggerStartParameters sp; qulonglong pid = it->toULongLong(); - QString remoteChannel = it->contains('@') ? it->section('@', 0, 0) : *it; + QString remoteChannel = it->contains(QLatin1Char('@')) ? + it->section(QLatin1Char('@'), 0, 0) : *it; uint port = 0; int pos = remoteChannel.indexOf(QLatin1Char(':')); if (pos != -1) @@ -1270,14 +1272,14 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it, } else if (port) { sp.startMode = AttachToRemoteServer; sp.remoteChannel = remoteChannel; - sp.executable = it->section('@', 1, 1); + sp.executable = it->section(QLatin1Char('@'), 1, 1); if (sp.remoteChannel.isEmpty()) { *errorMessage = DebuggerPlugin::tr("The parameter '%1' of option " "'%2' does not match the pattern <server:port>@<executable>@<architecture>.") .arg(*it, option); return false; } - sp.remoteArchitecture = it->section('@', 2, 2); + sp.remoteArchitecture = it->section(QLatin1Char('@'), 2, 2); sp.displayName = tr("Remote: \"%1\"").arg(sp.remoteChannel); sp.startMessage = tr("Attaching to remote server %1.") .arg(sp.remoteChannel); @@ -1317,8 +1319,8 @@ bool DebuggerPluginPrivate::parseArgument(QStringList::const_iterator &it, } DebuggerStartParameters sp; sp.startMode = AttachCrashedExternal; - sp.crashParameter = it->section(':', 0, 0); - sp.attachPID = it->section(':', 1, 1).toULongLong(); + sp.crashParameter = it->section(QLatin1Char(':'), 0, 0); + sp.attachPID = it->section(QLatin1Char(':'), 1, 1).toULongLong(); sp.displayName = tr("Crashed process %1").arg(sp.attachPID); sp.startMessage = tr("Attaching to crashed process %1").arg(sp.attachPID); sp.toolChainAbi = Abi::hostAbi(); @@ -1432,21 +1434,21 @@ void DebuggerPluginPrivate::debugProject() { ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance(); if (Project *pro = pe->startupProject()) - pe->runProject(pro, Constants::DEBUGMODE); + pe->runProject(pro, QLatin1String(Constants::DEBUGMODE)); } void DebuggerPluginPrivate::debugProjectWithoutDeploy() { ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance(); if (Project *pro = pe->startupProject()) - pe->runProject(pro, Constants::DEBUGMODE, true); + pe->runProject(pro, QLatin1String(Constants::DEBUGMODE), true); } void DebuggerPluginPrivate::debugProjectBreakMain() { ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance(); if (Project *pro = pe->startupProject()) - pe->runProject(pro, Constants::DEBUGMODE2); + pe->runProject(pro, QLatin1String(Constants::DEBUGMODE2)); } void DebuggerPluginPrivate::startExternalApplication() @@ -1568,9 +1570,9 @@ void DebuggerPluginPrivate::attachToRemoteServer(const QString &spec) { // spec is: server:port@executable@architecture DebuggerStartParameters sp; - sp.remoteChannel = spec.section('@', 0, 0); - sp.executable = spec.section('@', 1, 1); - sp.remoteArchitecture = spec.section('@', 2, 2); + sp.remoteChannel = spec.section(QLatin1Char('@'), 0, 0); + sp.executable = spec.section(QLatin1Char('@'), 1, 1); + sp.remoteArchitecture = spec.section(QLatin1Char('@'), 2, 2); sp.displayName = tr("Remote: \"%1\"").arg(sp.remoteChannel); sp.startMode = AttachToRemoteServer; sp.toolChainAbi = anyAbiOfBinary(sp.executable); @@ -1869,7 +1871,7 @@ void DebuggerPluginPrivate::requestContextMenu(ITextEditor *editor, if (editor->property("DisassemblerView").toBool()) { args.fileName = editor->file()->fileName(); QString line = editor->contents() - .section('\n', lineNumber - 1, lineNumber - 1); + .section(QLatin1Char('\n'), lineNumber - 1, lineNumber - 1); BreakpointResponse needle; needle.type = BreakpointByAddress; needle.address = DisassemblerLine::addressFromDisassemblyLine(line); @@ -1966,7 +1968,7 @@ void DebuggerPluginPrivate::toggleBreakpoint() const int lineNumber = textEditor->currentLine(); if (textEditor->property("DisassemblerView").toBool()) { QString line = textEditor->contents() - .section('\n', lineNumber - 1, lineNumber - 1); + .section(QLatin1Char('\n'), lineNumber - 1, lineNumber - 1); quint64 address = DisassemblerLine::addressFromDisassemblyLine(line); toggleBreakpointByAddress(address); } else if (lineNumber >= 0) { @@ -2021,7 +2023,7 @@ void DebuggerPluginPrivate::requestMark(ITextEditor *editor, if (editor->property("DisassemblerView").toBool()) { QString line = editor->contents() - .section('\n', lineNumber - 1, lineNumber - 1); + .section(QLatin1Char('\n'), lineNumber - 1, lineNumber - 1); quint64 address = DisassemblerLine::addressFromDisassemblyLine(line); toggleBreakpointByAddress(address); } else if (editor->file()) { @@ -2051,7 +2053,7 @@ void DebuggerPluginPrivate::displayDebugger(DebuggerEngine *engine, bool updateE void DebuggerPluginPrivate::startDebugger(RunControl *rc) { QTC_ASSERT(rc, return); - ProjectExplorerPlugin::instance()->startRunControl(rc, Constants::DEBUGMODE); + ProjectExplorerPlugin::instance()->startRunControl(rc, QLatin1String(Constants::DEBUGMODE)); } @@ -2421,7 +2423,7 @@ void DebuggerPluginPrivate::onModeChanged(IMode *mode) m_mainWindow->onModeChanged(mode); - if (mode->id() != Constants::MODE_DEBUG) { + if (mode->id() != QLatin1String(Constants::MODE_DEBUG)) { m_toolTipManager->leavingDebugMode(); return; } @@ -2466,7 +2468,7 @@ void DebuggerPluginPrivate::dumpLog() void DebuggerPluginPrivate::activatePreviousMode() { ModeManager *modeManager = ModeManager::instance(); - if (modeManager->currentMode() == modeManager->mode(MODE_DEBUG) + if (modeManager->currentMode() == modeManager->mode(QLatin1String(MODE_DEBUG)) && !m_previousMode.isEmpty()) { modeManager->activateMode(m_previousMode); m_previousMode.clear(); @@ -2711,7 +2713,7 @@ static QString formatStartParameters(DebuggerStartParameters &sp) if (!sp.gnuTarget.isEmpty()) str << "Gnu target: " << sp.gnuTarget << '\n'; str << "Sysroot: " << sp.sysroot << '\n'; - str << "Debug Source Location: " << sp.debugSourceLocation.join(":") << '\n'; + str << "Debug Source Location: " << sp.debugSourceLocation.join(QLatin1String(":")) << '\n'; str << "Symbol file: " << sp.symbolFileName << '\n'; if (sp.useServerStartScript) str << "Using server start script: " << sp.serverStartScript; @@ -2871,23 +2873,23 @@ void DebuggerPluginPrivate::extensionsInitialized() m_breakHandler = new BreakHandler; m_breakWindow = new BreakWindow; - m_breakWindow->setObjectName(DOCKWIDGET_BREAK); + m_breakWindow->setObjectName(QLatin1String(DOCKWIDGET_BREAK)); m_breakWindow->setModel(m_breakHandler->model()); //m_consoleWindow = new ConsoleWindow; //m_consoleWindow->setObjectName(QLatin1String("CppDebugConsole")); m_modulesWindow = new ModulesWindow; - m_modulesWindow->setObjectName(DOCKWIDGET_MODULES); + m_modulesWindow->setObjectName(QLatin1String(DOCKWIDGET_MODULES)); m_logWindow = new LogWindow; - m_logWindow->setObjectName(DOCKWIDGET_OUTPUT); + m_logWindow->setObjectName(QLatin1String(DOCKWIDGET_OUTPUT)); m_registerWindow = new RegisterWindow; - m_registerWindow->setObjectName(DOCKWIDGET_REGISTER); + m_registerWindow->setObjectName(QLatin1String(DOCKWIDGET_REGISTER)); m_stackWindow = new StackWindow; - m_stackWindow->setObjectName(DOCKWIDGET_STACK); + m_stackWindow->setObjectName(QLatin1String(DOCKWIDGET_STACK)); m_sourceFilesWindow = new SourceFilesWindow; - m_sourceFilesWindow->setObjectName(DOCKWIDGET_SOURCE_FILES); + m_sourceFilesWindow->setObjectName(QLatin1String(DOCKWIDGET_SOURCE_FILES)); m_threadsWindow = new ThreadsWindow; - m_threadsWindow->setObjectName(DOCKWIDGET_THREADS); + m_threadsWindow->setObjectName(QLatin1String(DOCKWIDGET_THREADS)); m_returnWindow = new WatchWindow(WatchWindow::ReturnType); m_returnWindow->setObjectName(QLatin1String("CppDebugReturn")); m_localsWindow = new WatchWindow(WatchWindow::LocalsType); @@ -2896,14 +2898,14 @@ void DebuggerPluginPrivate::extensionsInitialized() m_watchersWindow->setObjectName(QLatin1String("CppDebugWatchers")); m_scriptConsoleWindow = new QmlJSScriptConsoleWidget; m_scriptConsoleWindow->setWindowTitle(tr("QML Script Console")); - m_scriptConsoleWindow->setObjectName(DOCKWIDGET_QML_SCRIPTCONSOLE); + m_scriptConsoleWindow->setObjectName(QLatin1String(DOCKWIDGET_QML_SCRIPTCONSOLE)); connect(m_scriptConsoleWindow, SIGNAL(evaluateExpression(QString)), SLOT(evaluateExpression(QString))); // Snapshot m_snapshotHandler = new SnapshotHandler; m_snapshotWindow = new SnapshotWindow(m_snapshotHandler); - m_snapshotWindow->setObjectName(DOCKWIDGET_SNAPSHOTS); + m_snapshotWindow->setObjectName(QLatin1String(DOCKWIDGET_SNAPSHOTS)); m_snapshotWindow->setModel(m_snapshotHandler->model()); // Watchers @@ -3018,7 +3020,7 @@ void DebuggerPluginPrivate::extensionsInitialized() m_mainWindow->createDockWidget(QmlLanguage, m_scriptConsoleWindow); QSplitter *localsAndWatchers = new MiniSplitter(Qt::Vertical); - localsAndWatchers->setObjectName(DOCKWIDGET_WATCHERS); + localsAndWatchers->setObjectName(QLatin1String(DOCKWIDGET_WATCHERS)); localsAndWatchers->setWindowTitle(m_localsWindow->windowTitle()); localsAndWatchers->addWidget(m_localsWindow); localsAndWatchers->addWidget(m_returnWindow); @@ -3045,8 +3047,8 @@ void DebuggerPluginPrivate::extensionsInitialized() // The main "Start Debugging" action. act = m_startAction = new QAction(this); - QIcon debuggerIcon(":/projectexplorer/images/debugger_start_small.png"); - debuggerIcon.addFile(":/projectexplorer/images/debugger_start.png"); + QIcon debuggerIcon(QLatin1String(":/projectexplorer/images/debugger_start_small.png")); + debuggerIcon.addFile(QLatin1String(":/projectexplorer/images/debugger_start.png")); act->setIcon(debuggerIcon); act->setText(tr("Start Debugging")); connect(act, SIGNAL(triggered()), this, SLOT(debugProject())); @@ -3116,7 +3118,7 @@ void DebuggerPluginPrivate::extensionsInitialized() cmd = am->registerAction(m_startAction, Constants::DEBUG, globalcontext); cmd->setDefaultText(tr("Start Debugging")); - cmd->setDefaultKeySequence(QKeySequence(Constants::DEBUG_KEY)); + cmd->setDefaultKeySequence(QKeySequence(QLatin1String(Constants::DEBUG_KEY))); cmd->setAttribute(Command::CA_UpdateText); mstart->addAction(cmd, CC::G_DEFAULT_ONE); @@ -3206,7 +3208,7 @@ void DebuggerPluginPrivate::extensionsInitialized() cmd = am->registerAction(m_continueAction, Constants::CONTINUE, globalcontext); - cmd->setDefaultKeySequence(QKeySequence(Constants::DEBUG_KEY)); + cmd->setDefaultKeySequence(QKeySequence(QLatin1String(Constants::DEBUG_KEY))); debugMenu->addAction(cmd, CC::G_DEFAULT_ONE); cmd = am->registerAction(m_exitAction, @@ -3221,11 +3223,11 @@ void DebuggerPluginPrivate::extensionsInitialized() cmd = am->registerAction(m_hiddenStopAction, Constants::HIDDEN_STOP, globalcontext); - cmd->setDefaultKeySequence(QKeySequence(Constants::STOP_KEY)); + cmd->setDefaultKeySequence(QKeySequence(QLatin1String(Constants::STOP_KEY))); cmd = am->registerAction(m_abortAction, Constants::ABORT, globalcontext); - //cmd->setDefaultKeySequence(QKeySequence(Constants::RESET_KEY)); + //cmd->setDefaultKeySequence(QKeySequence(QLatin1String(Constants::RESET_KEY))); cmd->setDefaultText(tr("Reset Debugger")); debugMenu->addAction(cmd, CC::G_DEFAULT_ONE); @@ -3236,34 +3238,34 @@ void DebuggerPluginPrivate::extensionsInitialized() cmd = am->registerAction(m_nextAction, Constants::NEXT, globalcontext); - cmd->setDefaultKeySequence(QKeySequence(Constants::NEXT_KEY)); + cmd->setDefaultKeySequence(QKeySequence(QLatin1String(Constants::NEXT_KEY))); cmd->setAttribute(Command::CA_Hide); cmd->setAttribute(Command::CA_UpdateText); debugMenu->addAction(cmd); cmd = am->registerAction(m_stepAction, Constants::STEP, globalcontext); - cmd->setDefaultKeySequence(QKeySequence(Constants::STEP_KEY)); + cmd->setDefaultKeySequence(QKeySequence(QLatin1String(Constants::STEP_KEY))); cmd->setAttribute(Command::CA_Hide); cmd->setAttribute(Command::CA_UpdateText); debugMenu->addAction(cmd); cmd = am->registerAction(m_stepOutAction, Constants::STEPOUT, cppDebuggercontext); - cmd->setDefaultKeySequence(QKeySequence(Constants::STEPOUT_KEY)); + cmd->setDefaultKeySequence(QKeySequence(QLatin1String(Constants::STEPOUT_KEY))); cmd->setAttribute(Command::CA_Hide); debugMenu->addAction(cmd); cmd = am->registerAction(m_runToLineAction, "Debugger.RunToLine", cppDebuggercontext); - cmd->setDefaultKeySequence(QKeySequence(Constants::RUN_TO_LINE_KEY)); + cmd->setDefaultKeySequence(QKeySequence(QLatin1String(Constants::RUN_TO_LINE_KEY))); cmd->setAttribute(Command::CA_Hide); debugMenu->addAction(cmd); cmd = am->registerAction(m_runToSelectedFunctionAction, "Debugger.RunToSelectedFunction", cppDebuggercontext); cmd->setDefaultKeySequence(QKeySequence( - Constants::RUN_TO_SELECTED_FUNCTION_KEY)); + QLatin1String(Constants::RUN_TO_SELECTED_FUNCTION_KEY))); cmd->setAttribute(Command::CA_Hide); // Don't add to menu by default as keeping its enabled state // and text up-to-date is a lot of hassle. @@ -3281,7 +3283,7 @@ void DebuggerPluginPrivate::extensionsInitialized() cmd = am->registerAction(m_reverseDirectionAction, Constants::REVERSE, cppDebuggercontext); - cmd->setDefaultKeySequence(QKeySequence(Constants::REVERSE_KEY)); + cmd->setDefaultKeySequence(QKeySequence(QLatin1String(Constants::REVERSE_KEY))); cmd->setAttribute(Command::CA_Hide); debugMenu->addAction(cmd); @@ -3292,7 +3294,7 @@ void DebuggerPluginPrivate::extensionsInitialized() //cmd = am->registerAction(m_snapshotAction, // "Debugger.Snapshot", cppDebuggercontext); - //cmd->setDefaultKeySequence(QKeySequence(Constants::SNAPSHOT_KEY)); + //cmd->setDefaultKeySequence(QKeySequence(QLatin1String(Constants::SNAPSHOT_KEY))); //cmd->setAttribute(Command::CA_Hide); //debugMenu->addAction(cmd); @@ -3308,7 +3310,7 @@ void DebuggerPluginPrivate::extensionsInitialized() cmd = am->registerAction(m_breakAction, "Debugger.ToggleBreak", globalcontext); - cmd->setDefaultKeySequence(QKeySequence(Constants::TOGGLE_BREAK_KEY)); + cmd->setDefaultKeySequence(QKeySequence(QLatin1String(Constants::TOGGLE_BREAK_KEY))); debugMenu->addAction(cmd); connect(m_breakAction, SIGNAL(triggered()), SLOT(toggleBreakpoint())); @@ -3491,7 +3493,7 @@ void DebuggerPluginPrivate::showModuleSymbols(const QString &moduleName, w->setRootIsDecorated(false); w->setAlternatingRowColors(true); w->setSortingEnabled(true); - w->setObjectName("Symbols." + moduleName); + w->setObjectName(QLatin1String("Symbols.") + moduleName); QStringList header; header.append(tr("Symbol")); header.append(tr("Address")); diff --git a/src/plugins/debugger/debuggerrunner.cpp b/src/plugins/debugger/debuggerrunner.cpp index db59fd1b15..a2a4bec8a3 100644 --- a/src/plugins/debugger/debuggerrunner.cpp +++ b/src/plugins/debugger/debuggerrunner.cpp @@ -185,7 +185,7 @@ DebuggerRunControlPrivate::DebuggerRunControlPrivate(DebuggerRunControl *parent, DebuggerRunControl::DebuggerRunControl(RunConfiguration *runConfiguration, const DebuggerStartParameters &sp, const QPair<DebuggerEngineType, DebuggerEngineType> &masterSlaveEngineTypes) - : RunControl(runConfiguration, Constants::DEBUGMODE), + : RunControl(runConfiguration, QLatin1String(Constants::DEBUGMODE)), d(new DebuggerRunControlPrivate(this, runConfiguration)) { connect(this, SIGNAL(finished()), SLOT(handleFinished())); @@ -229,7 +229,7 @@ QString DebuggerRunControl::displayName() const QIcon DebuggerRunControl::icon() const { - return QIcon(ProjectExplorer::Constants::ICON_DEBUG_SMALL); + return QIcon(QLatin1String(ProjectExplorer::Constants::ICON_DEBUG_SMALL)); } void DebuggerRunControl::setCustomEnvironment(Utils::Environment env) @@ -551,7 +551,7 @@ static inline bool canUseEngine(DebuggerEngineType et, // Enabled? if ((et & cmdLineEnabledEngines) == 0) { result->errorDetails.push_back(DebuggerPlugin::tr("The debugger engine '%1' is disabled."). - arg(engineTypeName(et))); + arg(QLatin1String(engineTypeName(et)))); return false; } // Configured. @@ -636,7 +636,7 @@ DEBUGGER_EXPORT ConfigurationCheck checkDebugConfiguration(const DebuggerStartPa const QString msg = DebuggerPlugin::tr( "The preferred debugger engine for debugging binaries of type '%1' is not available.\n" "The debugger engine '%2' will be used as a fallback.\nDetails: %3"). - arg(sp.toolChainAbi.toString(), engineTypeName(usableType), + arg(sp.toolChainAbi.toString(), QLatin1String(engineTypeName(usableType)), result.errorDetails.join(QString(QLatin1Char('\n')))); debuggerCore()->showMessage(msg, LogWarning); showMessageBox(QMessageBox::Warning, DebuggerPlugin::tr("Warning"), msg); @@ -669,8 +669,8 @@ DebuggerRunControlFactory::DebuggerRunControlFactory(QObject *parent, bool DebuggerRunControlFactory::canRun(RunConfiguration *runConfiguration, const QString &mode) const { -// return mode == ProjectExplorer::Constants::DEBUGMODE; - return (mode == Constants::DEBUGMODE || mode == Constants::DEBUGMODE2) + return (mode == QLatin1String(Constants::DEBUGMODE) + || mode == QLatin1String(Constants::DEBUGMODE2)) && qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration); } @@ -768,8 +768,8 @@ static DebuggerStartParameters localStartParameters(RunConfiguration *runConfigu sp.environment.set(optimizerKey, _("1")); } - Utils::QtcProcess::addArg(&sp.processArgs, QString("-qmljsdebugger=port:%1,block").arg( - sp.qmlServerPort)); + Utils::QtcProcess::addArg(&sp.processArgs, + QString::fromLatin1("-qmljsdebugger=port:%1,block").arg(sp.qmlServerPort)); } // FIXME: If it's not yet build this will be empty and not filled @@ -784,11 +784,12 @@ static DebuggerStartParameters localStartParameters(RunConfiguration *runConfigu RunControl *DebuggerRunControlFactory::create (RunConfiguration *runConfiguration, const QString &mode) { - QTC_ASSERT(mode == Constants::DEBUGMODE || mode == Constants::DEBUGMODE2, return 0); + QTC_ASSERT(mode == QLatin1String(Constants::DEBUGMODE) + || mode == QLatin1String(Constants::DEBUGMODE2), return 0); DebuggerStartParameters sp = localStartParameters(runConfiguration); if (sp.startMode == NoStartMode) return 0; - if (mode == Constants::DEBUGMODE2) + if (mode == QLatin1String(Constants::DEBUGMODE2)) sp.breakOnMain = true; return create(sp, runConfiguration); } diff --git a/src/plugins/debugger/debuggertooltipmanager.cpp b/src/plugins/debugger/debuggertooltipmanager.cpp index 4f43312222..f716014873 100644 --- a/src/plugins/debugger/debuggertooltipmanager.cpp +++ b/src/plugins/debugger/debuggertooltipmanager.cpp @@ -794,7 +794,7 @@ DebuggerToolTipWidget *DebuggerToolTipWidget::loadSessionDataI(QXmlStreamReader if (debugToolTips) qDebug() << "Creating tooltip " << context << " from " << creationDate << offset; DebuggerToolTipWidget *rc = 0; - if (className == "Debugger::Internal::DebuggerToolTipWidget") + if (className == QLatin1String("Debugger::Internal::DebuggerToolTipWidget")) rc = new DebuggerToolTipWidget; if (rc) { rc->setContext(context); diff --git a/src/plugins/debugger/disassembleragent.cpp b/src/plugins/debugger/disassembleragent.cpp index 536a29e5d8..674eea73a6 100644 --- a/src/plugins/debugger/disassembleragent.cpp +++ b/src/plugins/debugger/disassembleragent.cpp @@ -306,7 +306,7 @@ void DisassemblerAgent::setContentsToEditor(const DisassemblerLines &contents) EditorManager *editorManager = EditorManager::instance(); if (!d->editor) { - QString titlePattern = "Disassembler"; + QString titlePattern = QLatin1String("Disassembler"); d->editor = qobject_cast<ITextEditor *>( editorManager->openEditorWithContents( Core::Constants::K_DEFAULT_TEXT_EDITOR_ID, diff --git a/src/plugins/debugger/disassemblerlines.cpp b/src/plugins/debugger/disassemblerlines.cpp index 42e3991e34..66b528ff82 100644 --- a/src/plugins/debugger/disassemblerlines.cpp +++ b/src/plugins/debugger/disassemblerlines.cpp @@ -62,7 +62,7 @@ void DisassemblerLine::fromString(const QString &unparsed) if (addr.size() >= 9 && addr.at(8) == QLatin1Char('`')) addr.remove(8, 1); - if (addr.endsWith(':')) // clang + if (addr.endsWith(QLatin1Char(':'))) // clang addr.chop(1); if (addr.startsWith(QLatin1String("0x"))) addr.remove(0, 2); @@ -151,28 +151,28 @@ void DisassemblerLines::appendUnparsed(const QString &unparsed) QString line = unparsed.trimmed(); if (line.isEmpty()) return; - if (line.startsWith("Current language:")) + if (line.startsWith(QLatin1String("Current language:"))) return; - if (line.startsWith("Dump of assembler")) { + if (line.startsWith(QLatin1String("Dump of assembler"))) { m_lastFunction.clear(); return; } - if (line.startsWith("The current source")) + if (line.startsWith(QLatin1String("The current source"))) return; - if (line.startsWith("End of assembler")) { + if (line.startsWith(QLatin1String("End of assembler"))) { m_lastFunction.clear(); return; } - if (line.startsWith("=> ")) + if (line.startsWith(QLatin1String("=> "))) line = line.mid(3); - if (line.startsWith("0x")) { + if (line.startsWith(QLatin1String("0x"))) { // Address line. - int pos1 = line.indexOf('<') + 1; - int posc = line.indexOf(':'); + int pos1 = line.indexOf(QLatin1Char('<')) + 1; + int posc = line.indexOf(QLatin1Char(':')); DisassemblerLine dl; - if (pos1 && line.indexOf("<UNDEFINED> instruction:") == -1) { - int pos2 = line.indexOf('+', pos1); - int pos3 = line.indexOf('>', pos1); + if (pos1 && line.indexOf(QLatin1String("<UNDEFINED> instruction:")) == -1) { + int pos2 = line.indexOf(QLatin1Char('+'), pos1); + int pos3 = line.indexOf(QLatin1Char('>'), pos1); if (pos1 < pos2 && pos2 < pos3) { QString function = line.mid(pos1, pos2 - pos1); if (function != m_lastFunction) { diff --git a/src/plugins/debugger/gdb/classicgdbengine.cpp b/src/plugins/debugger/gdb/classicgdbengine.cpp index 22e40ad7d0..adebbc6af1 100644 --- a/src/plugins/debugger/gdb/classicgdbengine.cpp +++ b/src/plugins/debugger/gdb/classicgdbengine.cpp @@ -54,6 +54,7 @@ #include <dlfcn.h> #endif +#include <cctype> #define PRECONDITION QTC_CHECK(!hasPython()) @@ -144,11 +145,11 @@ QString DumperHelper::toString(bool debug) const return rc; } const QString nameSpace = m_qtNamespace.isEmpty() - ? QCoreApplication::translate("QtDumperHelper", "<none>") : m_qtNamespace; + ? QCoreApplication::translate("QtDumperHelper", "<none>") : QLatin1String(m_qtNamespace); return QCoreApplication::translate("QtDumperHelper", "%n known types, Qt version: %1, Qt namespace: %2 Dumper version: %3", 0, QCoreApplication::CodecForTr, - m_nameTypeMap.size()).arg(qtVersionString(), nameSpace).arg(m_dumperVersion); + m_nameTypeMap.size()).arg(QLatin1String(qtVersionString()), nameSpace).arg(m_dumperVersion); } DumperHelper::Type DumperHelper::simpleType(const QByteArray &simpleType) const @@ -475,13 +476,13 @@ DumperHelper::SpecialSizeType DumperHelper::specialSizeType(const QByteArray &ty return SpecialSizeCount; } -static inline bool isInteger(const QString &n) +static inline bool isInteger(const QByteArray &n) { const int size = n.size(); if (!size) return false; for (int i = 0; i < size; i++) - if (!n.at(i).isDigit()) + if (!std::isdigit(n.at(i))) return false; return true; } @@ -506,12 +507,12 @@ void DumperHelper::evaluationParameters(const WatchData &data, for (int i = 0; i != inners.size(); ++i) inners[i] = inners[i].simplified(); - QString outertype = td.isTemplate ? td.tmplate : data.type; + QByteArray outertype = td.isTemplate ? td.tmplate : data.type; // adjust the data extract if (outertype == m_qtNamespace + "QWidget") outertype = m_qtNamespace + "QObject"; - QString inner = td.inner; + QByteArray inner = td.inner; const QByteArray zero = "0"; extraArgs.clear(); @@ -644,13 +645,13 @@ void DumperHelper::evaluationParameters(const WatchData &data, } inBuffer->clear(); - inBuffer->append(outertype.toUtf8()); + inBuffer->append(outertype); inBuffer->append('\0'); inBuffer->append(data.iname); inBuffer->append('\0'); inBuffer->append(data.exp); inBuffer->append('\0'); - inBuffer->append(inner.toUtf8()); + inBuffer->append(inner); inBuffer->append('\0'); inBuffer->append(data.iname); inBuffer->append('\0'); @@ -860,8 +861,8 @@ void GdbEngine::updateSubItemClassic(const WatchData &data0) // Try automatic dereferentiation data.exp = "(*(" + data.exp + "))"; data.type = data.type + '.'; // FIXME: fragile HACK to avoid recursion - if (data.value.startsWith("0x")) - data.value = "@" + data.value; + if (data.value.startsWith(QLatin1String("0x"))) + data.value.insert(0, QLatin1Char('@')); insertData(data); } else { data.setChildrenUnneeded(); @@ -1201,7 +1202,7 @@ void GdbEngine::handleStackListArgumentsClassic(const GdbResponse &response) } else { // Seems to occur on "RedHat 4 based Linux" gdb 7.0.1: // ^error,msg="Cannot access memory at address 0x0" - showMessage(_("UNEXPECTED RESPONSE: ") + response.toString()); + showMessage(_("UNEXPECTED RESPONSE: ") + QLatin1String(response.toString())); } } @@ -1239,7 +1240,7 @@ void GdbEngine::handleStackListLocalsClassic(const GdbResponse &response) if (!m_resultVarName.isEmpty()) { WatchData rd; rd.iname = "return.0"; - rd.name = "return"; + rd.name = QLatin1String("return"); rd.exp = m_resultVarName; list.append(rd); } @@ -1310,10 +1311,10 @@ void GdbEngine::handleDebuggingHelperVersionCheckClassic(const GdbResponse &resp if (response.resultClass == GdbResultDone) { QString value = _(response.data.findChild("value").data()); QString debuggeeQtVersion = value.section(QLatin1Char('"'), 1, 1); - QString dumperQtVersion = m_dumperHelper.qtVersionString(); + QString dumperQtVersion = QLatin1String(m_dumperHelper.qtVersionString()); if (debuggeeQtVersion.isEmpty()) { showMessage(_("DUMPER VERSION CHECK SKIPPED, NO qVersion() OUTPUT IN") - + response.toString()); + + QLatin1String(response.toString())); } else if (dumperQtVersion.isEmpty()) { showMessage(_("DUMPER VERSION CHECK SKIPPED, NO VERSION STRING")); } else if (dumperQtVersion != debuggeeQtVersion) { @@ -1328,7 +1329,7 @@ void GdbEngine::handleDebuggingHelperVersionCheckClassic(const GdbResponse &resp + dumperQtVersion); } } else { - showMessage("DUMPER VERSION CHECK NOT COMPLETED"); + showMessage(QLatin1String("DUMPER VERSION CHECK NOT COMPLETED")); } } @@ -1354,7 +1355,7 @@ void GdbEngine::handleVarListChildrenHelperClassic(const GdbMi &item, //iname += '.' + exp; postCommand(cmd, WatchUpdate, CB(handleVarListChildrenClassic), QVariant::fromValue(data)); - } else if (!startsWithDigit(exp) + } else if (!startsWithDigit(QLatin1String(exp)) && item.findChild("numchild").data() == "0") { // Happens for structs without data, e.g. interfaces. WatchData data; @@ -1393,7 +1394,7 @@ void GdbEngine::handleVarListChildrenHelperClassic(const GdbMi &item, data.setChildrenUnneeded(); data.name = _(exp); - if (data.type == data.name) { + if (data.name == QLatin1String(data.type)) { if (isPointerType(parent.type)) { data.exp = "*(" + parent.exp + ')'; data.name = _("*") + parent.name; diff --git a/src/plugins/debugger/gdb/codagdbadapter.cpp b/src/plugins/debugger/gdb/codagdbadapter.cpp index 0e9ad5e446..19425c2a50 100644 --- a/src/plugins/debugger/gdb/codagdbadapter.cpp +++ b/src/plugins/debugger/gdb/codagdbadapter.cpp @@ -167,7 +167,7 @@ CodaGdbAdapter::~CodaGdbAdapter() SymbianUtils::SymbianDeviceManager::instance()->releaseCodaDevice(m_codaDevice); cleanup(); - logMessage("Shutting down.\n"); + logMessage(QLatin1String("Shutting down.\n")); } void CodaGdbAdapter::setVerbose(const QVariant &value) @@ -375,7 +375,7 @@ void CodaGdbAdapter::codaEvent(const CodaEvent &e) } break; case CodaEvent::LoggingWriteEvent: // TODO: Not tested yet. - showMessage(e.toString() + '\n', AppOutput); + showMessage(e.toString() + QLatin1Char('\n'), AppOutput); break; default: break; @@ -416,7 +416,7 @@ void CodaGdbAdapter::logMessage(const QString &msg, int channel) // void CodaGdbAdapter::handleGdbConnection() { - logMessage("HANDLING GDB CONNECTION"); + logMessage(QLatin1String("HANDLING GDB CONNECTION")); QTC_CHECK(m_gdbConnection == 0); m_gdbConnection = m_gdbServer->nextPendingConnection(); QTC_ASSERT(m_gdbConnection, return); @@ -437,9 +437,10 @@ void CodaGdbAdapter::readGdbServerCommand() QByteArray packet = m_gdbConnection->readAll(); m_gdbReadBuffer.append(packet); - logMessage("gdb: -> " + currentTime() + ' ' + QString::fromAscii(packet)); + logMessage(QLatin1String("gdb: -> ") + currentTime() + + QLatin1Char(' ') + QString::fromAscii(packet)); if (packet != m_gdbReadBuffer) - logMessage(_("buffer: ") + m_gdbReadBuffer); + logMessage(_("buffer: ") + QString::fromAscii(m_gdbReadBuffer)); QByteArray &ba = m_gdbReadBuffer; while (ba.size()) { @@ -452,27 +453,27 @@ void CodaGdbAdapter::readGdbServerCommand() } if (code == '-') { - logMessage("NAK: Retransmission requested", LogError); + logMessage(QLatin1String("NAK: Retransmission requested"), LogError); // This seems too harsh. //emit adapterCrashed("Communication problem encountered."); continue; } if (code == char(0x03)) { - logMessage("INTERRUPT RECEIVED"); + logMessage(QLatin1String("INTERRUPT RECEIVED")); interruptInferior(); continue; } if (code != '$') { - logMessage("Broken package (2) " + quoteUnprintableLatin1(ba) - + Coda::hexNumber(code), LogError); + logMessage(QLatin1String("Broken package (2) ") + quoteUnprintableLatin1(ba) + + QLatin1String(Coda::hexNumber(code)), LogError); continue; } int pos = ba.indexOf('#'); if (pos == -1) { - logMessage("Invalid checksum format in " + logMessage(QLatin1String("Invalid checksum format in ") + quoteUnprintableLatin1(ba), LogError); continue; } @@ -480,7 +481,7 @@ void CodaGdbAdapter::readGdbServerCommand() bool ok = false; uint checkSum = ba.mid(pos + 1, 2).toUInt(&ok, 16); if (!ok) { - logMessage("Invalid checksum format 2 in " + logMessage(QLatin1String("Invalid checksum format 2 in ") + quoteUnprintableLatin1(ba), LogError); return; } @@ -491,8 +492,8 @@ void CodaGdbAdapter::readGdbServerCommand() sum += ba.at(i); if (sum != checkSum) { - logMessage(QString("ERROR: Packet checksum wrong: %1 %2 in " - + quoteUnprintableLatin1(ba)).arg(checkSum).arg(sum), LogError); + logMessage(QString::fromLatin1("ERROR: Packet checksum wrong: %1 %2 in %3"). + arg(checkSum).arg(sum).arg(quoteUnprintableLatin1(ba)), LogError); } QByteArray cmd = ba.left(pos); @@ -527,7 +528,7 @@ void CodaGdbAdapter::sendGdbServerAck() { if (!m_gdbAckMode) return; - logMessage("gdb: <- +"); + logMessage(QLatin1String("gdb: <- +")); sendGdbServerPacket(QByteArray(1, '+'), false); } @@ -548,7 +549,9 @@ void CodaGdbAdapter::sendGdbServerMessage(const QByteArray &msg, const QByteArra packet.append('#'); packet.append(checkSum); int pad = qMax(0, 24 - packet.size()); - logMessage("gdb: <- " + currentTime() + ' ' + packet + QByteArray(pad, ' ') + logNote); + logMessage(QLatin1String("gdb: <- ") + currentTime() + QLatin1Char(' ') + + QString::fromAscii(packet) + QString(pad, QLatin1Char(' ')) + + QLatin1String(logNote)); sendGdbServerPacket(packet, true); } @@ -869,7 +872,7 @@ void CodaGdbAdapter::handleGdbServerCommand(const QByteArray &cmd) else if (cmd == "QStartNoAckMode") { //$qSupported#37 - logMessage("Handling 'QStartNoAckMode'"); + logMessage(QLatin1String("Handling 'QStartNoAckMode'")); sendGdbServerAck(); sendGdbServerMessage("OK", "ack no-ack mode"); m_gdbAckMode = false; @@ -932,7 +935,8 @@ void CodaGdbAdapter::handleGdbServerCommand(const QByteArray &cmd) CodaCallback(this, &CodaGdbAdapter::handleAndReportSetBreakpoint), bp); } else { - logMessage(_("MISPARSED BREAKPOINT '") + cmd + "'')" , LogError); + logMessage(_("MISPARSED BREAKPOINT '") + QLatin1String(cmd) + + QLatin1String("'')") , LogError); } } @@ -1059,7 +1063,7 @@ void CodaGdbAdapter::startAdapter() const QString reason = m_codaDevice.isNull() ? tr("Could not obtain device.") : m_codaDevice->device()->errorString(); - const QString msg = QString("Could not open serial device '%1': %2") + const QString msg = QString::fromLatin1("Could not open serial device '%1': %2") .arg(parameters.remoteChannel, reason); logMessage(msg, LogError); m_engine->handleAdapterStartFailed(msg, QString()); @@ -1091,14 +1095,14 @@ void CodaGdbAdapter::startAdapter() const QPair<QString, unsigned short> address = splitIpAddressSpec(m_gdbServerName); if (!m_gdbServer->listen(QHostAddress(address.first), address.second)) { - QString msg = QString("Unable to start the gdb server at %1: %2.") + QString msg = QString::fromLatin1("Unable to start the gdb server at %1: %2.") .arg(m_gdbServerName).arg(m_gdbServer->errorString()); logMessage(msg, LogError); m_engine->handleAdapterStartFailed(msg, QString()); return; } - logMessage(QString("Gdb server running on %1.\nLittle endian assumed.") + logMessage(QString::fromLatin1("Gdb server running on %1.\nLittle endian assumed.") .arg(m_gdbServerName)); connect(m_gdbServer, SIGNAL(newConnection()), @@ -1246,7 +1250,7 @@ void CodaGdbAdapter::shutdownAdapter() } else { // Something is wrong, gdb crashed. Kill debuggee (see handleDeleteProcess2) if (m_codaDevice && m_codaDevice->device()->isOpen()) { - logMessage("Emergency shutdown of CODA", LogError); + logMessage(QLatin1String("Emergency shutdown of CODA"), LogError); sendRunControlTerminateCommand(); } } @@ -1300,8 +1304,9 @@ void CodaGdbAdapter::handleRegisterChildren(const CodaCommandResult &result) QTC_ASSERT(m_codaDevice, return); const QByteArray contextId = result.cookie.toByteArray(); if (!result) { - logMessage("Error retrieving register children of " + contextId - + ": " + result.errorString(), LogError); + logMessage(QLatin1String("Error retrieving register children of ") + + result.cookie.toString() + QLatin1String(": ") + + result.errorString(), LogError); return; } // Parse out registers. @@ -1346,7 +1351,7 @@ void CodaGdbAdapter::handleReadRegisters(const CodaCommandResult &result) { // Check for errors. if (!result) { - logMessage("ERROR: " + result.errorString(), LogError); + logMessage(QLatin1String("ERROR: ") + result.errorString(), LogError); return; } if (result.values.isEmpty() || result.values.front().type() != Json::JsonValue::String) { @@ -1435,9 +1440,10 @@ void CodaGdbAdapter::handleAndReportSetBreakpoint(const CodaCommandResult &resul void CodaGdbAdapter::handleClearBreakpoint(const CodaCommandResult &result) { - logMessage("CLEAR BREAKPOINT "); + logMessage(QLatin1String("CLEAR BREAKPOINT ")); if (!result) - logMessage("Error clearing breakpoint: " + result.errorString(), LogError); + logMessage(QLatin1String("Error clearing breakpoint: ") + + result.errorString(), LogError); sendGdbServerMessage("OK"); } @@ -1551,7 +1557,7 @@ void CodaGdbAdapter::tryAnswerGdbMemoryRequest(bool buffered) } // Happens when chunks are not combined QTC_CHECK(false); - showMessage("CHUNKS NOT COMBINED"); + showMessage(QLatin1String("CHUNKS NOT COMBINED")); # ifdef MEMORY_DEBUG qDebug() << "CHUNKS NOT COMBINED"; it = m_snapshot.memory.begin(); @@ -1639,8 +1645,8 @@ void CodaGdbAdapter::sendStepRange() void CodaGdbAdapter::handleStep(const CodaCommandResult &result) { if (!result) { // Try fallback with Continue. - logMessage(_("Error while stepping: %1 (fallback to 'continue')"). - arg(result.errorString()), LogWarning); + logMessage(QString::fromLatin1("Error while stepping: %1 (fallback to 'continue')"). + arg(result.errorString()), LogWarning); sendContinue(); // Doing nothing as below does not work as gdb seems to insist on // making some progress through a 'step'. @@ -1650,7 +1656,7 @@ void CodaGdbAdapter::handleStep(const CodaCommandResult &result) return; } // The gdb server response is triggered later by the Stop Reply packet. - logMessage("STEP FINISHED " + currentTime()); + logMessage(QLatin1String("STEP FINISHED ") + currentTime()); } } // namespace Internal diff --git a/src/plugins/debugger/gdb/coregdbadapter.cpp b/src/plugins/debugger/gdb/coregdbadapter.cpp index 7319f3a31c..d123eb0ed5 100644 --- a/src/plugins/debugger/gdb/coregdbadapter.cpp +++ b/src/plugins/debugger/gdb/coregdbadapter.cpp @@ -133,7 +133,7 @@ void CoreGdbAdapter::handleTemporaryTargetCore(const GdbResponse &response) return; } - m_executable = console.mid(pos1 + 1, pos2 - pos1 - 1); + m_executable = QLatin1String(console.mid(pos1 + 1, pos2 - pos1 - 1)); // Strip off command line arguments. FIXME: make robust. int idx = m_executable.indexOf(_c(' ')); if (idx >= 0) diff --git a/src/plugins/debugger/gdb/gdbengine.h b/src/plugins/debugger/gdb/gdbengine.h index 63df57d4bc..a0a5870ba3 100644 --- a/src/plugins/debugger/gdb/gdbengine.h +++ b/src/plugins/debugger/gdb/gdbengine.h @@ -169,7 +169,7 @@ public: static QString msgDumperOutdated(double requiredVersion, double currentVersion); private: - typedef QMap<QString, Type> NameTypeMap; + typedef QMap<QByteArray, Type> NameTypeMap; typedef QMap<QByteArray, int> SizeCache; // Look up a simple (namespace) type diff --git a/src/plugins/debugger/gdb/localplaingdbadapter.cpp b/src/plugins/debugger/gdb/localplaingdbadapter.cpp index 56112e48b6..cf48d1e147 100644 --- a/src/plugins/debugger/gdb/localplaingdbadapter.cpp +++ b/src/plugins/debugger/gdb/localplaingdbadapter.cpp @@ -165,7 +165,7 @@ void LocalPlainGdbAdapter::checkForReleaseBuild() // "30 .debug_info 00087d36 00000000 00000000 0006bbd5 2**0\n" // " CONTENTS, READONLY, DEBUGGING" if (ba.contains("Sections:") && !ba.contains(".debug_info")) { - showMessageBox(QMessageBox::Information, "Warning", + showMessageBox(QMessageBox::Information, tr("Warning"), tr("This does not seem to be a \"Debug\" build.\n" "Setting breakpoints by file name and line number may fail.")); } diff --git a/src/plugins/debugger/gdb/symbian.cpp b/src/plugins/debugger/gdb/symbian.cpp index a28ad80436..36a11cd602 100644 --- a/src/plugins/debugger/gdb/symbian.cpp +++ b/src/plugins/debugger/gdb/symbian.cpp @@ -87,7 +87,7 @@ void MemoryRange::operator-=(const MemoryRange &other) QDebug operator<<(QDebug d, const MemoryRange &range) { - return d << QString("[%1,%2] (size %3) ") + return d << QString::fromLatin1("[%1,%2] (size %3) ") .arg(range.from, 0, 16).arg(range.to, 0, 16).arg(range.size()); } diff --git a/src/plugins/debugger/logwindow.cpp b/src/plugins/debugger/logwindow.cpp index 23d8bf621e..151ec45328 100644 --- a/src/plugins/debugger/logwindow.cpp +++ b/src/plugins/debugger/logwindow.cpp @@ -64,36 +64,6 @@ namespace Debugger { namespace Internal { -static QChar charForChannel(int channel) -{ - switch (channel) { - case LogDebug: return 'd'; - case LogWarning: return 'w'; - case LogError: return 'e'; - case LogInput: return '<'; - case LogOutput: return '>'; - case LogStatus: return 's'; - case LogTime: return 't'; - case LogMisc: - default: return ' '; - } -} - -static LogChannel channelForChar(QChar c) -{ - switch (c.unicode()) { - case 'd': return LogDebug; - case 'w': return LogWarning; - case 'e': return LogError; - case '<': return LogInput; - case '>': return LogOutput; - case 's': return LogStatus; - case 't': return LogTime; - default: return LogMisc; - } -} - - ///////////////////////////////////////////////////////////////////// // // OutputHighlighter @@ -111,7 +81,7 @@ private: void highlightBlock(const QString &text) { QTextCharFormat format; - switch (channelForChar(text.isEmpty() ? QChar() : text.at(0))) { + switch (LogWindow::channelForChar(text.isEmpty() ? QChar() : text.at(0))) { case LogInput: format.setForeground(Qt::blue); setFormat(1, text.size(), format); @@ -266,7 +236,7 @@ private: int n = 0; // cut time string - if (line.size() > 18 && line.at(0) == '[') + if (line.size() > 18 && line.at(0) == QLatin1Char('[')) line = line.mid(18); //qDebug() << line; @@ -312,7 +282,7 @@ public: public slots: void gotoResult(int i) { - QString needle = QString::number(i) + '^'; + QString needle = QString::number(i) + QLatin1Char('^'); QString needle2 = QLatin1Char('>') + needle; QTextCursor cursor(document()); do { @@ -343,7 +313,7 @@ LogWindow::LogWindow(QWidget *parent) : QWidget(parent) { setWindowTitle(tr("Debugger Log")); - setObjectName("Log"); + setObjectName(QLatin1String("Log")); m_ignoreNextInputEcho = false; @@ -366,7 +336,7 @@ LogWindow::LogWindow(QWidget *parent) m_commandLabel = new QLabel(tr("Command:"), this); m_commandEdit = new QLineEdit(this); m_commandEdit->setFrame(false); - m_commandEdit->setObjectName("DebuggerInput"); + m_commandEdit->setObjectName(QLatin1String("DebuggerInput")); m_commandEdit->setCompleter(new Utils::HistoryCompleter( Core::ICore::instance()->settings(), m_commandEdit)); QHBoxLayout *commandBox = new QHBoxLayout; @@ -438,7 +408,7 @@ void LogWindow::showOutput(int channel, const QString &output) if (debuggerCore()->boolSetting(LogTimeStamps)) m_combinedText->appendPlainText(charForChannel(LogTime) + logTimeStamp()); - foreach (QString line, output.split('\n')) { + foreach (QString line, output.split(QLatin1Char('\n'))) { // FIXME: QTextEdit asserts on really long lines... const int n = 30000; if (line.size() > n) { @@ -536,6 +506,35 @@ bool LogWindow::writeLogContents(const QPlainTextEdit *editor, QWidget *parent) return success; } +QChar LogWindow::charForChannel(int channel) +{ + switch (channel) { + case LogDebug: return QLatin1Char('d'); + case LogWarning: return QLatin1Char('w'); + case LogError: return QLatin1Char('e'); + case LogInput: return QLatin1Char('<'); + case LogOutput: return QLatin1Char('>'); + case LogStatus: return QLatin1Char('s'); + case LogTime: return QLatin1Char('t'); + case LogMisc: + default: return QLatin1Char(' '); + } +} + +LogChannel LogWindow::channelForChar(QChar c) +{ + switch (c.unicode()) { + case 'd': return LogDebug; + case 'w': return LogWarning; + case 'e': return LogError; + case '<': return LogInput; + case '>': return LogOutput; + case 's': return LogStatus; + case 't': return LogTime; + default: return LogMisc; + } +} + } // namespace Internal } // namespace Debugger diff --git a/src/plugins/debugger/logwindow.h b/src/plugins/debugger/logwindow.h index 638919edfe..411b275b60 100644 --- a/src/plugins/debugger/logwindow.h +++ b/src/plugins/debugger/logwindow.h @@ -33,6 +33,8 @@ #ifndef DEBUGGER_LOGWINDOW_H #define DEBUGGER_LOGWINDOW_H +#include "debuggerconstants.h" + #include <QtGui/QWidget> QT_BEGIN_NAMESPACE @@ -61,6 +63,9 @@ public: static bool writeLogContents(const QPlainTextEdit *editor, QWidget *parent = 0); + static QChar charForChannel(int channel); + static LogChannel channelForChar(QChar c); + public slots: void clearContents(); void sendCommand(); diff --git a/src/plugins/debugger/memoryagent.cpp b/src/plugins/debugger/memoryagent.cpp index e7cedbc4aa..3866e25182 100644 --- a/src/plugins/debugger/memoryagent.cpp +++ b/src/plugins/debugger/memoryagent.cpp @@ -165,7 +165,7 @@ bool MemoryAgent::doCreateBinEditor(quint64 addr, unsigned flags, if (flags & DebuggerEngine::MemoryView) { // Ask BIN editor plugin for factory service and have it create a bin editor widget. QWidget *binEditor = 0; - if (QObject *factory = ExtensionSystem::PluginManager::instance()->getObjectByClassName("BINEditor::BinEditorWidgetFactory")) + if (QObject *factory = ExtensionSystem::PluginManager::instance()->getObjectByClassName(QLatin1String("BINEditor::BinEditorWidgetFactory"))) binEditor = ExtensionSystem::invoke<QWidget *>(factory, "createWidget", (QWidget *)0); if (!binEditor) return false; diff --git a/src/plugins/debugger/moduleshandler.cpp b/src/plugins/debugger/moduleshandler.cpp index 704ef2ef72..642f7cdd8c 100644 --- a/src/plugins/debugger/moduleshandler.cpp +++ b/src/plugins/debugger/moduleshandler.cpp @@ -56,12 +56,12 @@ QVariant ModulesModel::headerData(int section, { if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { static QString headers[] = { - tr("Module name") + " ", - tr("Module path") + " ", - tr("Symbols read") + " ", - tr("Symbols type") + " ", - tr("Start address") + " ", - tr("End address") + " " + tr("Module name") + QLatin1String(" "), + tr("Module path") + QLatin1String(" "), + tr("Symbols read") + QLatin1String(" "), + tr("Symbols type") + QLatin1String(" "), + tr("Start address") + QLatin1String(" "), + tr("End address") + QLatin1String(" ") }; return headers[section]; } diff --git a/src/plugins/debugger/outputcollector.cpp b/src/plugins/debugger/outputcollector.cpp index 4814f5df75..63f0407292 100644 --- a/src/plugins/debugger/outputcollector.cpp +++ b/src/plugins/debugger/outputcollector.cpp @@ -106,13 +106,15 @@ bool OutputCollector::listen() if (!::mkfifo(codedServerPath.constData(), 0600)) break; if (errno != EEXIST) { - m_errorString = tr("Cannot create FiFo %1: %2").arg(m_serverPath, strerror(errno)); + m_errorString = tr("Cannot create FiFo %1: %2"). + arg(m_serverPath, QString::fromLocal8Bit(strerror(errno))); m_serverPath.clear(); return false; } } if ((m_serverFd = ::open(codedServerPath.constData(), O_RDONLY|O_NONBLOCK)) < 0) { - m_errorString = tr("Cannot open FiFo %1: %2").arg(m_serverPath, strerror(errno)); + m_errorString = tr("Cannot open FiFo %1: %2"). + arg(m_serverPath, QString::fromLocal8Bit(strerror(errno))); m_serverPath.clear(); return false; } diff --git a/src/plugins/debugger/registerhandler.cpp b/src/plugins/debugger/registerhandler.cpp index a9b545579f..2718a6f43b 100644 --- a/src/plugins/debugger/registerhandler.cpp +++ b/src/plugins/debugger/registerhandler.cpp @@ -383,7 +383,7 @@ QString Register::displayValue(int base, int strlen) const return QString::fromAscii("%1").arg(editV.toULongLong(), strlen, base); const QString stringValue = editV.toString(); if (stringValue.size() < strlen) - return QString(strlen - stringValue.size(), QLatin1Char(' ')) + value; + return QString(strlen - stringValue.size(), QLatin1Char(' ')) + QLatin1String(value); return stringValue; } @@ -413,13 +413,13 @@ QVariant RegisterHandler::data(const QModelIndex &index, int role) const switch (index.column()) { case 0: { switch (bitWidth) { - case 8: return "[Bytes]"; - case 16: return "[Words]"; - case 32: return "[DWords]"; - case 64: return "[QWords]"; - case 128: return "[TWords]"; - case -32: return "[Single]"; - case -64: return "[Double]"; + case 8: return QLatin1String("[Bytes]"); + case 16: return QLatin1String("[Words]"); + case 32: return QLatin1String("[DWords]"); + case 64: return QLatin1String("[QWords]"); + case 128: return QLatin1String("[TWords]"); + case -32: return QLatin1String("[Single]"); + case -64: return QLatin1String("[Double]"); return QVariant(bitWidth); } } @@ -438,7 +438,7 @@ QVariant RegisterHandler::data(const QModelIndex &index, int role) const switch (index.column()) { case 0: { const QString padding = QLatin1String(" "); - return QVariant(padding + reg.name + padding); + return QVariant(padding + QLatin1String(reg.name) + padding); //return QVariant(reg.name); } case 1: // Display: Pad value for alignment @@ -475,7 +475,7 @@ Qt::ItemFlags RegisterHandler::flags(const QModelIndex &idx) const const Qt::ItemFlags notEditable = Qt::ItemIsSelectable|Qt::ItemIsEnabled; // Can edit registers if they are hex numbers and not arrays. if (idx.column() == 1 - && IntegerWatchLineEdit::isUnsignedHexNumber(m_registers.at(idx.row()).value)) + && IntegerWatchLineEdit::isUnsignedHexNumber(QLatin1String(m_registers.at(idx.row()).value))) return notEditable | Qt::ItemIsEditable; return notEditable; } diff --git a/src/plugins/debugger/registerwindow.cpp b/src/plugins/debugger/registerwindow.cpp index 1b038f897f..635ed6f365 100644 --- a/src/plugins/debugger/registerwindow.cpp +++ b/src/plugins/debugger/registerwindow.cpp @@ -113,8 +113,8 @@ public: QTC_ASSERT(lineEdit, return); const int base = currentHandler()->numberBase(); QString value = lineEdit->text(); - if (base == 16 && !value.startsWith("0x")) - value = "0x" + value; + if (base == 16 && !value.startsWith(QLatin1String("0x"))) + value.insert(0, QLatin1String("0x")); currentEngine()->setRegisterValue(index.row(), value); } diff --git a/src/plugins/debugger/shared/backtrace.cpp b/src/plugins/debugger/shared/backtrace.cpp index 0fdbeefc37..764804cc4a 100644 --- a/src/plugins/debugger/shared/backtrace.cpp +++ b/src/plugins/debugger/shared/backtrace.cpp @@ -55,9 +55,9 @@ void dumpBacktrace(int maxdepth) qDebug() << "0x" + QByteArray::number(quintptr(bt[i]), 16); QProcess proc; QStringList args; - args.append("-e"); + args.append(QLatin1String("-e")); args.append(QCoreApplication::arguments().at(0)); - proc.start("addr2line", args); + proc.start(QLatin1String("addr2line"), args); proc.waitForStarted(); for (int i = 0; i < qMin(size, maxdepth); i++) proc.write("0x" + QByteArray::number(quintptr(bt[i]), 16) + '\n'); diff --git a/src/plugins/debugger/shared/hostutils.cpp b/src/plugins/debugger/shared/hostutils.cpp index 5e766c5605..671e94336d 100644 --- a/src/plugins/debugger/shared/hostutils.cpp +++ b/src/plugins/debugger/shared/hostutils.cpp @@ -390,7 +390,7 @@ static QList<ProcData> unixProcessList() if (!file.open(QIODevice::ReadOnly)) continue; // process may have exited - const QStringList data = QString::fromLocal8Bit(file.readAll()).split(' '); + const QStringList data = QString::fromLocal8Bit(file.readAll()).split(QLatin1Char(' ')); ProcData proc; proc.ppid = procId; proc.name = data.at(1); diff --git a/src/plugins/debugger/sourceagent.cpp b/src/plugins/debugger/sourceagent.cpp index 6cab8368b9..1a39cb7994 100644 --- a/src/plugins/debugger/sourceagent.cpp +++ b/src/plugins/debugger/sourceagent.cpp @@ -90,7 +90,7 @@ public: SourceAgentPrivate::SourceAgentPrivate() : editor(0) - , producer("remote") + , producer(QLatin1String("remote")) { locationMark = new TextEditor::ITextMark; locationMark->setIcon(debuggerCore()->locationMarkIcon()); diff --git a/src/plugins/debugger/sourcefileshandler.cpp b/src/plugins/debugger/sourcefileshandler.cpp index 84699eacf0..5982952be2 100644 --- a/src/plugins/debugger/sourcefileshandler.cpp +++ b/src/plugins/debugger/sourcefileshandler.cpp @@ -61,8 +61,8 @@ QVariant SourceFilesHandler::headerData(int section, { if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { static QString headers[] = { - tr("Internal name") + " ", - tr("Full name") + " ", + tr("Internal name") + QLatin1String(" "), + tr("Full name") + QLatin1String(" "), }; return headers[section]; } diff --git a/src/plugins/debugger/stackwindow.cpp b/src/plugins/debugger/stackwindow.cpp index b58f2d68f4..a410949315 100644 --- a/src/plugins/debugger/stackwindow.cpp +++ b/src/plugins/debugger/stackwindow.cpp @@ -189,9 +189,9 @@ void StackWindow::copyContentsToClipboard() for (int j = 0; j != m; ++j) { QModelIndex index = model()->index(i, j); str += model()->data(index).toString(); - str += '\t'; + str += QLatin1Char('\t'); } - str += '\n'; + str += QLatin1Char('\n'); } QClipboard *clipboard = QApplication::clipboard(); # ifdef Q_WS_X11 diff --git a/src/plugins/debugger/threadshandler.cpp b/src/plugins/debugger/threadshandler.cpp index 2ace6247ce..f225ad4954 100644 --- a/src/plugins/debugger/threadshandler.cpp +++ b/src/plugins/debugger/threadshandler.cpp @@ -159,7 +159,7 @@ QVariant ThreadsHandler::data(const QModelIndex &index, int role) const case ThreadData::NameColumn: return thread.name; case ThreadData::ComboNameColumn: - return QString("#%1 %2").arg(thread.id).arg(thread.name); + return QString::fromLatin1("#%1 %2").arg(thread.id).arg(thread.name); } case Qt::ToolTipRole: return threadToolTip(thread); @@ -265,7 +265,7 @@ void ThreadsHandler::updateThreadBox() { QStringList list; foreach (const ThreadData &thread, m_threads) - list.append(QString("#%1 %2").arg(thread.id).arg(thread.name)); + list.append(QString::fromLatin1("#%1 %2").arg(thread.id).arg(thread.name)); debuggerCore()->setThreads(list, m_currentIndex); } diff --git a/src/plugins/debugger/watchdata.cpp b/src/plugins/debugger/watchdata.cpp index 63d367b270..5fcabb6604 100644 --- a/src/plugins/debugger/watchdata.cpp +++ b/src/plugins/debugger/watchdata.cpp @@ -179,7 +179,7 @@ void WatchData::setError(const QString &msg) void WatchData::setValue(const QString &value0) { value = value0; - if (value == "{...}") { + if (value == QLatin1String("{...}")) { value.clear(); hasChildren = true; // at least one... } @@ -191,26 +191,26 @@ void WatchData::setValue(const QString &value0) } // avoid duplicated information - if (value.startsWith(QLatin1Char('(')) && value.contains(") 0x")) - value = value.mid(value.lastIndexOf(") 0x") + 2); + if (value.startsWith(QLatin1Char('(')) && value.contains(QLatin1String(") 0x"))) + value.remove(0, value.lastIndexOf(QLatin1String(") 0x")) + 2); // doubles are sometimes displayed as "@0x6141378: 1.2". // I don't want that. - if (/*isIntOrFloatType(type) && */ value.startsWith("@0x") - && value.contains(':')) { - value = value.mid(value.indexOf(':') + 2); + if (/*isIntOrFloatType(type) && */ value.startsWith(QLatin1String("@0x")) + && value.contains(QLatin1Char(':'))) { + value.remove(0, value.indexOf(QLatin1Char(':')) + 2); setHasChildren(false); } // "numchild" is sometimes lying //MODEL_DEBUG("\n\n\nPOINTER: " << type << value); if (isPointerType(type)) - setHasChildren(value != "0x0" && value != "<null>" + setHasChildren(value != QLatin1String("0x0") && value != QLatin1String("<null>") && !isCharPointerType(type)); // pointer type information is available in the 'type' // column. No need to duplicate it here. - if (value.startsWith(QLatin1Char('(') + type + ") 0x")) + if (value.startsWith(QLatin1Char('(') + QLatin1String(type) + QLatin1String(") 0x"))) value = value.section(QLatin1Char(' '), -1, -1); setValueUnneeded(); @@ -303,7 +303,7 @@ QString WatchData::toString() const if (!iname.isEmpty()) str << "iname=\"" << iname << doubleQuoteComma; str << "sortId=\"" << sortId << doubleQuoteComma; - if (!name.isEmpty() && name != iname) + if (!name.isEmpty() && name != QLatin1String(iname)) str << "name=\"" << name << doubleQuoteComma; if (error) str << "error,"; @@ -369,8 +369,8 @@ QString WatchData::toToolTip() const QTextStream str(&res); str << "<html><body><table>"; formatToolTipRow(str, tr("Name"), name); - formatToolTipRow(str, tr("Expression"), exp); - formatToolTipRow(str, tr("Internal Type"), type); + formatToolTipRow(str, tr("Expression"), QLatin1String(exp)); + formatToolTipRow(str, tr("Internal Type"), QLatin1String(type)); formatToolTipRow(str, tr("Displayed Type"), displayedType); QString val = value; if (value.size() > 1000) { @@ -385,7 +385,7 @@ QString WatchData::toToolTip() const QString::fromAscii(hexReferencingAddress())); if (size) formatToolTipRow(str, tr("Size"), QString::number(size)); - formatToolTipRow(str, tr("Internal ID"), iname); + formatToolTipRow(str, tr("Internal ID"), QLatin1String(iname)); formatToolTipRow(str, tr("Generation"), QString::number(generation)); str << "</table></body></html>"; diff --git a/src/plugins/debugger/watchdelegatewidgets.cpp b/src/plugins/debugger/watchdelegatewidgets.cpp index 4cd97049e9..cb167d70f7 100644 --- a/src/plugins/debugger/watchdelegatewidgets.cpp +++ b/src/plugins/debugger/watchdelegatewidgets.cpp @@ -116,7 +116,7 @@ QValidator::State IntegerValidator::validateEntry(const QString &s, int base, bo return QValidator::Intermediate; int pos = 0; // Skip sign. - if (signedV && s.at(pos) == '-') { + if (signedV && s.at(pos) == QLatin1Char('-')) { pos++; if (pos == size) return QValidator::Intermediate; diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 1264f95f01..03e4bd2724 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -305,7 +305,7 @@ static QString niceTypeHelper(const QByteArray &typeIn) const Cache::const_iterator it = cache.constFind(typeIn); if (it != cache.constEnd()) return it.value(); - const QString simplified = CPlusPlus::simplifySTLType(typeIn); + const QString simplified = CPlusPlus::simplifySTLType(QLatin1String(typeIn)); cache.insert(typeIn, simplified); // For simplicity, also cache unmodified types return simplified; } @@ -329,7 +329,7 @@ QString WatchModel::removeInitialNamespace(QString str) const str = str.mid(5); if (!debuggerCore()->boolSetting(ShowQtNamespace)) { const QByteArray qtNamespace = engine()->qtNamespace(); - if (!qtNamespace.isEmpty() && str.startsWith(qtNamespace)) + if (!qtNamespace.isEmpty() && str.startsWith(QLatin1String(qtNamespace))) str = str.mid(qtNamespace.size()); } return str; @@ -341,8 +341,8 @@ QString WatchModel::displayType(const WatchData &data) const ? niceTypeHelper(data.type) : data.displayedType; if (data.bitsize) - base += QString(":%1").arg(data.bitsize); - base.remove('\''); + base += QString::fromLatin1(":%1").arg(data.bitsize); + base.remove(QLatin1Char('\'')); return base; } @@ -363,11 +363,11 @@ template <class IntType> QString reformatInteger(IntType value, int format) { switch (format) { case HexadecimalFormat: - return ("(hex) ") + QString::number(value, 16); + return QLatin1String("(hex) ") + QString::number(value, 16); case BinaryFormat: - return ("(bin) ") + QString::number(value, 2); + return QLatin1String("(bin) ") + QString::number(value, 2); case OctalFormat: - return ("(oct) ") + QString::number(value, 8); + return QLatin1String("(oct) ") + QString::number(value, 8); } return QString::number(value); // not reached } @@ -405,13 +405,13 @@ static QString quoteUnprintable(const QString &str) if (u >= 32 && u < 127) encoded += c; else if (u == '\r') - encoded += "\\r"; + encoded += QLatin1String("\\r"); else if (u == '\t') - encoded += "\\t"; + encoded += QLatin1String("\\t"); else if (u == '\n') - encoded += "\\n"; + encoded += QLatin1String("\\n"); else - encoded += QString("\\%1") + encoded += QString::fromLatin1("\\%1") .arg(c.unicode(), 3, 8, QLatin1Char('0')); } return encoded; @@ -421,10 +421,10 @@ static QString quoteUnprintable(const QString &str) if (c.isPrint()) { encoded += c; } else if (WatchHandler::unprintableBase() == 8) { - encoded += QString("\\%1") + encoded += QString::fromLatin1("\\%1") .arg(c.unicode(), 3, 8, QLatin1Char('0')); } else { - encoded += QString("\\u%1") + encoded += QString::fromLatin1("\\u%1") .arg(c.unicode(), 4, 16, QLatin1Char('0')); } } @@ -481,12 +481,12 @@ QString WatchModel::formattedValue(const WatchData &data) const return WatchHandler::tr("<invalid>"); if (result == QLatin1String("<not accessible>")) return WatchHandler::tr("<not accessible>"); - if (result.endsWith(" items>")) { + if (result.endsWith(QLatin1String(" items>"))) { // '<10 items>' or '<>10 items>' (more than) bool ok; const bool moreThan = result.at(1) == QLatin1Char('>'); const int numberPos = moreThan ? 2 : 1; - const int len = result.indexOf(' ') - numberPos; + const int len = result.indexOf(QLatin1Char(' ')) - numberPos; const int size = result.mid(numberPos, len).toInt(&ok); QTC_ASSERT(ok, qWarning("WatchHandler: Invalid item count '%s'", qPrintable(result))) @@ -976,14 +976,14 @@ QStringList WatchHandler::typeFormatList(const WatchData &data) const << tr("Binary") << tr("Octal"); // Hack: Compensate for namespaces. - QString type = stripForFormat(data.type); - int pos = type.indexOf("::Q"); - if (pos >= 0 && type.count(':') == 2) - type = type.mid(pos + 2); - pos = type.indexOf('<'); + QString type = QLatin1String(stripForFormat(data.type)); + int pos = type.indexOf(QLatin1String("::Q")); + if (pos >= 0 && type.count(QLatin1Char(':')) == 2) + type.remove(0, pos + 2); + pos = type.indexOf(QLatin1Char('<')); if (pos >= 0) - type = type.left(pos); - type.replace(':', '_'); + type.truncate(pos); + type.replace(QLatin1Char(':'), QLatin1Char('_')); return m_reportedTypeFormats.value(type); } @@ -1242,7 +1242,7 @@ WatchHandler::WatchHandler(DebuggerEngine *engine) { m_engine = engine; m_inChange = false; - m_watcherCounter = debuggerCore()->sessionValue("Watchers") + m_watcherCounter = debuggerCore()->sessionValue(QLatin1String("Watchers")) .toStringList().count(); m_return = new WatchModel(this, ReturnWatch); @@ -1418,7 +1418,7 @@ void WatchHandler::watchExpression(const QString &exp) data.iname = watcherName(data.exp); if (m_engine->state() == DebuggerNotReady) { data.setAllUnneeded(); - data.setValue(" "); + data.setValue(QString(QLatin1Char(' '))); data.setHasChildren(false); insertData(data); } else if (m_engine->isSynchronous()) { @@ -1515,7 +1515,7 @@ void WatchHandler::showEditValue(const WatchData &data) QProcess *p = qobject_cast<QProcess *>(w); if (!p) { p = new QProcess; - p->start(cmd); + p->start(QLatin1String(cmd)); p->waitForStarted(); m_editHandlers[key] = p; } @@ -1568,21 +1568,21 @@ QStringList WatchHandler::watchedExpressions() QHashIterator<QByteArray, int> it(m_watcherNames); while (it.hasNext()) { it.next(); - const QString &watcherName = it.key(); + const QByteArray &watcherName = it.key(); if (!watcherName.isEmpty()) - watcherNames.push_back(watcherName); + watcherNames.push_back(QLatin1String(watcherName)); } return watcherNames; } void WatchHandler::saveWatchers() { - debuggerCore()->setSessionValue("Watchers", QVariant(watchedExpressions())); + debuggerCore()->setSessionValue(QLatin1String("Watchers"), QVariant(watchedExpressions())); } void WatchHandler::loadTypeFormats() { - QVariant value = debuggerCore()->sessionValue("DefaultFormats"); + QVariant value = debuggerCore()->sessionValue(QLatin1String("DefaultFormats")); QMap<QString, QVariant> typeFormats = value.toMap(); QMapIterator<QString, QVariant> it(typeFormats); while (it.hasNext()) { @@ -1600,12 +1600,13 @@ void WatchHandler::saveTypeFormats() it.next(); const int format = it.value(); if (format != DecimalFormat) { - const QString key = it.key().trimmed(); + const QByteArray key = it.key().trimmed(); if (!key.isEmpty()) - typeFormats.insert(key, format); + typeFormats.insert(QLatin1String(key), format); } } - debuggerCore()->setSessionValue("DefaultFormats", QVariant(typeFormats)); + debuggerCore()->setSessionValue(QLatin1String("DefaultFormats"), + QVariant(typeFormats)); } void WatchHandler::saveSessionData() @@ -1619,7 +1620,7 @@ void WatchHandler::loadSessionData() loadTypeFormats(); m_watcherNames.clear(); m_watcherCounter = 0; - QVariant value = debuggerCore()->sessionValue("Watchers"); + QVariant value = debuggerCore()->sessionValue(QLatin1String("Watchers")); foreach (WatchItem *item, m_watchers->rootItem()->children) m_watchers->destroyItem(item); foreach (const QString &exp, value.toStringList()) @@ -1637,7 +1638,7 @@ void WatchHandler::updateWatchers() WatchData data; data.iname = watcherName(exp); data.setAllNeeded(); - data.name = exp; + data.name = QLatin1String(exp); data.exp = exp; insertData(data); } @@ -1687,7 +1688,7 @@ const WatchData *WatchHandler::findItem(const QByteArray &iname) const QString WatchHandler::displayForAutoTest(const QByteArray &iname) const { const WatchModel *model = modelForIName(iname); - QTC_ASSERT(model, return 0); + QTC_ASSERT(model, return QString()); return model->displayForAutoTest(iname); } @@ -1777,7 +1778,7 @@ QByteArray WatchHandler::individualFormatRequests() const void WatchHandler::addTypeFormats(const QByteArray &type, const QStringList &formats) { - m_reportedTypeFormats.insert(stripForFormat(type), formats); + m_reportedTypeFormats.insert(QLatin1String(stripForFormat(type)), formats); } QString WatchHandler::editorContents() diff --git a/src/plugins/debugger/watchhandler.h b/src/plugins/debugger/watchhandler.h index 8f46c751c8..7edbf39cde 100644 --- a/src/plugins/debugger/watchhandler.h +++ b/src/plugins/debugger/watchhandler.h @@ -216,7 +216,7 @@ private: bool m_inChange; // QWidgets and QProcesses taking care of special displays. - typedef QMap<QString, QPointer<QObject> > EditHandlers; + typedef QMap<QByteArray, QPointer<QObject> > EditHandlers; EditHandlers m_editHandlers; static QHash<QByteArray, int> m_watcherNames; diff --git a/src/plugins/debugger/watchutils.cpp b/src/plugins/debugger/watchutils.cpp index 6d6aa39ddc..7b0291e5db 100644 --- a/src/plugins/debugger/watchutils.cpp +++ b/src/plugins/debugger/watchutils.cpp @@ -510,10 +510,10 @@ QString quoteUnprintableLatin1(const QByteArray &ba) for (int i = 0, n = ba.size(); i != n; ++i) { const unsigned char c = ba.at(i); if (isprint(c)) { - res += c; + res += QLatin1Char(c); } else { qsnprintf(buf, sizeof(buf) - 1, "\\%x", int(c)); - res += buf; + res += QLatin1String(buf); } } return res; @@ -669,7 +669,7 @@ QString cppExpressionAt(TextEditor::ITextEditor *editor, int pos, const QPlainTextEdit *plaintext = qobject_cast<QPlainTextEdit*>(editor->widget()); if (!plaintext) - return QByteArray(); + return QString(); QString expr = plaintext->textCursor().selectedText(); CppModelManagerInterface *modelManager = CppModelManagerInterface::instance(); @@ -698,7 +698,7 @@ QString cppExpressionAt(TextEditor::ITextEditor *editor, int pos, *function = AbstractEditorSupport::functionAt(modelManager, file->fileName(), *line, *column); - return expr.toUtf8(); + return expr; } QString cppFunctionAt(const QString &fileName, int line) diff --git a/src/plugins/debugger/watchwindow.cpp b/src/plugins/debugger/watchwindow.cpp index 26e12474ea..aa82de1499 100644 --- a/src/plugins/debugger/watchwindow.cpp +++ b/src/plugins/debugger/watchwindow.cpp @@ -536,7 +536,7 @@ void WatchWindow::keyPressEvent(QKeyEvent *ev) void WatchWindow::dragEnterEvent(QDragEnterEvent *ev) { //QTreeView::dragEnterEvent(ev); - if (ev->mimeData()->hasFormat("text/plain")) { + if (ev->mimeData()->hasText()) { ev->setDropAction(Qt::CopyAction); ev->accept(); } @@ -545,7 +545,7 @@ void WatchWindow::dragEnterEvent(QDragEnterEvent *ev) void WatchWindow::dragMoveEvent(QDragMoveEvent *ev) { //QTreeView::dragMoveEvent(ev); - if (ev->mimeData()->hasFormat("text/plain")) { + if (ev->mimeData()->hasText()) { ev->setDropAction(Qt::CopyAction); ev->accept(); } @@ -553,7 +553,7 @@ void WatchWindow::dragMoveEvent(QDragMoveEvent *ev) void WatchWindow::dropEvent(QDropEvent *ev) { - if (ev->mimeData()->hasFormat("text/plain")) { + if (ev->mimeData()->hasText()) { watchExpression(ev->mimeData()->text()); //ev->acceptProposedAction(); ev->setDropAction(Qt::CopyAction); |