Commit 81f14bb2 authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

Fix some code scanning issues.

QString: Use QChar/char where appropriate, do not use QString::null
parent 14ffb1e4
......@@ -984,10 +984,10 @@ QString CMakeCbpParser::compilerName() const
void CMakeBuildTarget::clear()
{
executable = QString::null;
makeCommand = QString::null;
makeCleanCommand = QString::null;
workingDirectory = QString::null;
title = QString::null;
executable.clear();
makeCommand.clear();
makeCleanCommand.clear();
workingDirectory.clear();
title.clear();
}
......@@ -131,7 +131,7 @@ QString CMakeManager::findCbpFile(const QDir &directory)
if (cbpFile.endsWith(QLatin1String(".cbp")))
return directory.path() + QLatin1Char('/') + cbpFile;
}
return QString::null;
return QString();
}
// This code is duplicated from qtversionmanager
......
......@@ -308,33 +308,33 @@ QByteArray GdbMi::toString(bool multiline, int indent) const
break;
case Const:
if (!m_name.isEmpty())
result += m_name + "=";
result += "\"" + escapeCString(m_data) + "\"";
result += m_name + '=';
result += '"' + escapeCString(m_data) + '"';
break;
case Tuple:
if (!m_name.isEmpty())
result += m_name + "=";
result += m_name + '=';
if (multiline) {
result += "{\n";
dumpChildren(&result, multiline, indent + 1);
result += '\n' + ind(indent) + "}";
result += '\n' + ind(indent) + '}';
} else {
result += "{";
result += '{';
dumpChildren(&result, multiline, indent + 1);
result += "}";
result += '}';
}
break;
case List:
if (!m_name.isEmpty())
result += m_name + "=";
result += m_name + '=';
if (multiline) {
result += "[\n";
dumpChildren(&result, multiline, indent + 1);
result += '\n' + ind(indent) + "]";
result += '\n' + ind(indent) + ']';
} else {
result += "[";
result += '[';
dumpChildren(&result, multiline, indent + 1);
result += "]";
result += ']';
}
break;
}
......
......@@ -371,7 +371,7 @@ QString FormWindowEditor::contextHelpId() const
QString FormWindowEditor::contents() const
{
if (!m_formWindow)
return QString::null;
return QString();
// Activate once all Qt branches around have integrated 4.5.2
// (Kinetic)
/*
......
......@@ -885,7 +885,7 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
if (m_submode == ChangeSubMode) {
removeSelectedText(true);
if (!dotCommand.isEmpty())
setDotCommand("c" + dotCommand);
setDotCommand(QLatin1Char('c') + dotCommand);
if (m_movetype == MoveLineWise) {
insertAutomaticIndentation(true);
}
......@@ -896,7 +896,7 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
} else if (m_submode == DeleteSubMode) {
removeSelectedText();
if (!dotCommand.isEmpty())
setDotCommand("d" + dotCommand);
setDotCommand(QLatin1Char('d') + dotCommand);
if (m_movetype == MoveLineWise)
handleStartOfLine();
m_submode = NoSubMode;
......@@ -922,7 +922,7 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
if (m_subsubmode == InvertCaseSubSubMode) {
invertCaseSelectedText();
if (!dotCommand.isEmpty())
setDotCommand("~" + dotCommand);
setDotCommand(QLatin1Char('~') + dotCommand);
} else if (m_subsubmode == UpCaseSubSubMode) {
upCaseSelectedText();
if (!dotCommand.isEmpty())
......@@ -1204,7 +1204,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
// Recognize ZZ and ZQ as aliases for ":x" and ":q!".
m_submode = NoSubMode;
if (key == 'Z')
handleCommand("x");
handleCommand(QString(QLatin1Char('x')));
else if (key == 'Q')
handleCommand("q!");
} else if (m_subsubmode == FtSubSubMode) {
......@@ -1251,14 +1251,14 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
m_movetype = MoveExclusive;
moveToStartOfLine();
setTargetColumn();
finishMovement("0");
finishMovement(QString(QLatin1Char('0')));
} else {
m_mvcount.append(QChar(key));
}
} else if (key == '^') {
moveToFirstNonBlankOnLine();
m_movetype = MoveExclusive;
finishMovement("^");
finishMovement(QString(QLatin1Char('^')));
} else if (0 && key == ',') {
// FIXME: fakevim uses ',' by itself, so it is incompatible
m_subsubmode = FtSubSubMode;
......@@ -1403,7 +1403,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
} else if (key == 'A') {
enterInsertMode();
moveBehindEndOfLine();
setDotCommand("A");
setDotCommand(QString(QLatin1Char('A')));
m_lastInsertion.clear();
updateMiniBuffer();
} else if (key == control('a')) {
......@@ -1433,7 +1433,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
setAnchor();
moveToEndOfLine();
m_submode = ChangeSubMode;
setDotCommand("C");
setDotCommand(QString(QLatin1Char('C')));
finishMovement();
} else if (key == control('c')) {
if (isNoVisualMode())
......@@ -1476,7 +1476,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
moveDown(qMax(count() - 1, 0));
m_movetype = MoveInclusive;
moveToEndOfLine();
setDotCommand("D");
setDotCommand(QString(QLatin1Char('D')));
finishMovement();
} else if ((key == 'D' || key == 'X') &&
(isVisualCharMode() || isVisualLineMode())) {
......@@ -1526,7 +1526,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
} else if (key == 'g' || key == 'G') {
QString dotCommand = QString("%1G").arg(count());
if (key == 'G' && m_mvcount.isEmpty())
dotCommand = "G";
dotCommand = QString(QLatin1Char('G'));
if (key == 'g')
m_gflag = false;
int n = (key == 'g') ? 1 : linesInDocument();
......@@ -1557,13 +1557,13 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
handleStartOfLine();
finishMovement();
} else if (key == 'i' || key == Key_Insert) {
setDotCommand("i"); // setDotCommand("%1i", count());
setDotCommand(QString(QLatin1Char('i'))); // setDotCommand("%1i", count());
enterInsertMode();
updateMiniBuffer();
if (atEndOfLine())
moveLeft();
} else if (key == 'I') {
setDotCommand("I"); // setDotCommand("%1I", count());
setDotCommand(QString(QLatin1Char('I'))); // setDotCommand("%1I", count());
enterInsertMode();
if (m_gflag)
moveToStartOfLine();
......@@ -1597,7 +1597,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|| characterAtCursor() == '\t')
moveRight();
removeSelectedText();
m_tc.insertText(" ");
m_tc.insertText(QString(QLatin1Char(' ')));
}
}
if (!m_gflag)
......@@ -1685,14 +1685,14 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
finishMovement();
} else if (key == 'r') {
m_submode = ReplaceSubMode;
setDotCommand("r");
setDotCommand(QString(QLatin1Char('r')));
} else if (key == 'R') {
// FIXME: right now we repeat the insertion count() times,
// but not the deletion
m_lastInsertion.clear();
enterInsertMode();
m_submode = ReplaceSubMode;
setDotCommand("R");
setDotCommand(QString(QLatin1Char('R')));
updateMiniBuffer();
} else if (key == control('r')) {
redo();
......
......@@ -60,7 +60,7 @@ void ChangeSelectionDialog::setRepository(const QString &s)
void ChangeSelectionDialog::selectWorkingDirectory()
{
static QString location = QString();
static QString location;
location = QFileDialog::getExistingDirectory(this,
tr("Select Git repository"),
location);
......
......@@ -49,10 +49,11 @@ QList<FilterEntry> BaseFileFilter::matchesFor(const QString &origEntry)
QList<FilterEntry> badMatches;
QString needle = trimWildcards(origEntry);
QStringMatcher matcher(needle, Qt::CaseInsensitive);
const QRegExp regexp("*"+needle+"*", Qt::CaseInsensitive, QRegExp::Wildcard);
const QChar asterisk = QLatin1Char('*');
const QRegExp regexp(asterisk + needle+ asterisk, Qt::CaseInsensitive, QRegExp::Wildcard);
if (!regexp.isValid())
return matches;
bool hasWildcard = (needle.contains('*') || needle.contains('?'));
bool hasWildcard = (needle.contains(asterisk) || needle.contains('?'));
QStringList searchListPaths;
QStringList searchListNames;
if (!m_previousEntry.isEmpty() && !m_forceNewSearchList && needle.contains(m_previousEntry)) {
......
......@@ -85,7 +85,7 @@ void LocatorFiltersFilter::accept(FilterEntry selection) const
{
ILocatorFilter *filter = selection.internalData.value<ILocatorFilter*>();
if (filter)
m_locatorWidget->show(filter->shortcutString() + " ",
m_locatorWidget->show(filter->shortcutString() + QLatin1Char(' '),
filter->shortcutString().length() + 1);
}
......
......@@ -1307,7 +1307,7 @@ QString PerforcePlugin::clientFilePath(const QString &serverFilePath)
const PerforceResponse response = runP4Cmd(m_settings.topLevelSymLinkTarget(), args,
ShowBusyCursor|RunFullySynchronous|CommandToWindow|StdErrToWindow|ErrorToWindow);
if (response.error)
return QString::null;
return QString();
QRegExp r(QLatin1String("\\.\\.\\.\\sclientFile\\s(.+)\n"));
r.setMinimal(true);
......@@ -1325,19 +1325,19 @@ QString PerforcePlugin::pendingChangesData()
const PerforceResponse userResponse = runP4Cmd(m_settings.topLevelSymLinkTarget(), args,
RunFullySynchronous|CommandToWindow|StdErrToWindow|ErrorToWindow);
if (userResponse.error)
return QString::null;
return QString();
QRegExp r(QLatin1String("User\\sname:\\s(\\S+)\\s*\n"));
QTC_ASSERT(r.isValid(), return QString())
r.setMinimal(true);
const QString user = r.indexIn(userResponse.stdOut) != -1 ? r.cap(1).trimmed() : QString::null;
const QString user = r.indexIn(userResponse.stdOut) != -1 ? r.cap(1).trimmed() : QString();
if (user.isEmpty())
return QString::null;
return QString();
args.clear();
args << QLatin1String("changes") << QLatin1String("-s") << QLatin1String("pending") << QLatin1String("-u") << user;
const PerforceResponse dataResponse = runP4Cmd(m_settings.topLevelSymLinkTarget(), args,
RunFullySynchronous|CommandToWindow|StdErrToWindow|ErrorToWindow);
return dataResponse.error ? QString::null : dataResponse.stdOut;
return dataResponse.error ? QString() : dataResponse.stdOut;
}
PerforcePlugin::~PerforcePlugin()
......
......@@ -101,7 +101,7 @@ void SettingsPageWidget::setSettings(const PerforceSettings &s)
void SettingsPageWidget::setStatusText(const QString &t)
{
m_ui.errorLabel->setStyleSheet(QString::null);
m_ui.errorLabel->setStyleSheet(QString());
m_ui.errorLabel->setText(t);
}
......
......@@ -398,7 +398,7 @@ QString CustomExecutableRunConfiguration::baseEnvironmentText() const
} else if (m_baseEnvironmentBase == CustomExecutableRunConfiguration::BuildEnvironmentBase) {
return tr("Build Environment");
}
return QString::null;
return QString();
}
ProjectExplorer::Environment CustomExecutableRunConfiguration::baseEnvironment() const
......
......@@ -54,7 +54,7 @@ QString DebuggingHelperLibrary::findSystemQt(const Environment &env)
}
}
}
return QString::null;
return QString();
}
QStringList DebuggingHelperLibrary::debuggingHelperLibraryDirectories(const QString &qtInstallData)
......@@ -75,7 +75,7 @@ QString DebuggingHelperLibrary::qtInstallDataDir(const QString &qmakePath)
proc.start(qmakePath, QStringList() << QLatin1String("-query") << QLatin1String("QT_INSTALL_DATA"));
if (proc.waitForFinished())
return QString(proc.readAll().trimmed());
return QString::null;
return QString();
}
// Debugging Helper Library
......@@ -136,7 +136,7 @@ QString DebuggingHelperLibrary::buildDebuggingHelperLibrary(const QString &qmake
const QString directory = copyDebuggingHelperLibrary(qtInstallDataDir(qmakePath), &errorMessage);
if (directory.isEmpty())
return errorMessage;
return buildDebuggingHelperLibrary(directory, make, qmakePath, QString::null, env);
return buildDebuggingHelperLibrary(directory, make, qmakePath, QString(), env);
}
// Copy helper source files to a target directory, replacing older files.
......@@ -245,7 +245,7 @@ QString DebuggingHelperLibrary::qtVersionForQMake(const QString &qmakePath)
QProcess qmake;
qmake.start(qmakePath, QStringList(QLatin1String("--version")));
if (!qmake.waitForFinished())
return QString::null;
return QString();
QString output = qmake.readAllStandardOutput();
QRegExp regexp(QLatin1String("(QMake version|QMake version:)[\\s]*([\\d.]*)"), Qt::CaseInsensitive);
regexp.indexIn(output);
......
......@@ -183,7 +183,7 @@ QString Environment::searchInPath(QString executable) const
{
// qDebug()<<"looking for "<<executable<< "in PATH: "<<m_values.value("PATH");
if (executable.isEmpty())
return QString::null;
return QString();
QFileInfo fi(executable);
if (fi.isAbsolute() && fi.exists())
return executable;
......@@ -203,7 +203,7 @@ QString Environment::searchInPath(QString executable) const
return fi.absoluteFilePath();
}
}
return QString::null;
return QString();
}
QStringList Environment::path() const
......
......@@ -1137,7 +1137,7 @@ void ProjectExplorerPlugin::determineSessionToRestoreAtStartup()
// We have command line arguments, try to find a session in them
QStringList arguments = ExtensionSystem::PluginManager::instance()->arguments();
// Default to no session loading
d->m_sessionToRestoreAtStartup = QString::null;
d->m_sessionToRestoreAtStartup.clear();
foreach (const QString &arg, arguments) {
if (sessions.contains(arg)) {
// Session argument
......@@ -1295,7 +1295,7 @@ void ProjectExplorerPlugin::buildQueueFinished(bool success)
d->m_buildManager->showTaskWindow();
}
d->m_delayedRunConfiguration = 0;
d->m_runMode = QString::null;
d->m_runMode.clear();
}
void ProjectExplorerPlugin::setCurrent(Project *project, QString filePath, Node *node)
......@@ -1417,7 +1417,7 @@ bool ProjectExplorerPlugin::saveModifiedFiles()
bool alwaysSave = false;
Core::FileManager *fm = Core::ICore::instance()->fileManager();
fm->saveModifiedFiles(filesToSave, &cancelled, QString::null,
fm->saveModifiedFiles(filesToSave, &cancelled, QString(),
"Always save files before build", &alwaysSave);
if (cancelled)
......
......@@ -471,7 +471,7 @@ void MaemoRunConfiguration::updateTarget()
if (m_cachedTargetInformationValid)
return;
m_executable = QString::null;
m_executable.clear();
m_cachedTargetInformationValid = true;
Qt4TargetInformation info = qt4Project()->targetInformation(qt4Project()->activeQt4BuildConfiguration(),
......
......@@ -152,7 +152,8 @@ void AbstractMaemoRunControl::deploy()
QStringList cmdArgs;
cmdArgs << "-P" << sshPort() << options() << deployable.fileName
<< (devConfig.uname + "@" + devConfig.host + ":" + remoteDir());
<< (devConfig.uname + QLatin1Char('@') + devConfig.host +
QLatin1Char(':') + remoteDir());
deployProcess.setWorkingDirectory(deployable.dir);
deployProcess.start(runConfig->scpCmd(), cmdArgs);
......@@ -473,7 +474,7 @@ MaemoDebugRunControl::MaemoDebugRunControl(RunConfiguration *runConfiguration)
startParams->startMode = Debugger::StartRemote;
startParams->executable = executableOnHost();
startParams->remoteChannel
= devConfig.host + ":" + QString::number(devConfig.gdbServerPort);
= devConfig.host + QLatin1Char(':') + QString::number(devConfig.gdbServerPort);
startParams->remoteArchitecture = "arm";
startParams->sysRoot = runConfig->sysRoot();
startParams->toolChainType = ToolChain::GCC_MAEMO;
......
......@@ -345,10 +345,10 @@ void S60DeviceRunConfiguration::updateTarget()
tr("Could not parse %1. The QtS60 Device run configuration %2 can not be started.")
.arg(m_proFilePath).arg(displayName()));
}
m_targetName = QString::null;
m_baseFileName = QString::null;
m_packageTemplateFileName = QString::null;
m_platform = QString::null;
m_targetName.clear();
m_baseFileName.clear();
m_packageTemplateFileName.clear();
m_platform.clear();
m_cachedTargetInformationValid = true;
emit targetInformationChanged();
return;
......
......@@ -243,7 +243,7 @@ bool S60Devices::detectQtForDevices()
continue;
QFile qtDll(QString("%1/epoc32/release/winscw/udeb/QtCore.dll").arg(m_devices.at(i).epocRoot));
if (!qtDll.exists() || !qtDll.open(QIODevice::ReadOnly)) {
m_devices[i].qt = QString();
m_devices[i].qt.clear();
continue;
}
QByteArray buffer;
......
......@@ -167,7 +167,7 @@ void S60EmulatorRunConfiguration::updateTarget()
tr("Could not parse %1. The Qt for Symbian emulator run configuration %2 can not be started.")
.arg(m_proFilePath).arg(displayName()));
}
m_executable = QString::null;
m_executable.clear();
m_cachedTargetInformationValid = true;
emit targetInformationChanged();
return;
......
......@@ -139,11 +139,7 @@ Qt4Project *Qt4BuildConfiguration::qt4Project() const
QString Qt4BuildConfiguration::baseEnvironmentText() const
{
if (useSystemEnvironment())
return tr("System Environment");
else
return tr("Clean Environment");
return QString::null;
return useSystemEnvironment() ? tr("System Environment") : tr("Clean Environment");
}
ProjectExplorer::Environment Qt4BuildConfiguration::baseEnvironment() const
......@@ -270,7 +266,7 @@ QString Qt4BuildConfiguration::defaultMakeTarget() const
{
ToolChain *tc = toolChain();
if (!tc)
return QString::null;
return QString();
const QtVersion::QmakeBuildConfigs buildConfig = qmakeBuildConfiguration();
switch (tc->type()) {
......@@ -285,7 +281,7 @@ QString Qt4BuildConfiguration::defaultMakeTarget() const
default:
break;
}
return QString::null;
return QString();
}
QtVersion *Qt4BuildConfiguration::qtVersion() const
......
......@@ -101,12 +101,12 @@ QString Qt4PriFile::fileName() const
QString Qt4PriFile::defaultPath() const
{
return QString::null;
return QString();
}
QString Qt4PriFile::suggestedFileName() const
{
return QString::null;
return QString();
}
QString Qt4PriFile::mimeType() const
......
......@@ -518,7 +518,7 @@ QString Qt4RunConfiguration::baseEnvironmentText() const
return tr("System Environment");
else if (m_baseEnvironmentBase == Qt4RunConfiguration::BuildEnvironmentBase)
return tr("Build Environment");
return QString::null;
return QString();
}
ProjectExplorer::Environment Qt4RunConfiguration::baseEnvironment() const
......@@ -561,7 +561,7 @@ void Qt4RunConfiguration::setWorkingDirectory(const QString &wd)
{
if (wd.isEmpty()) {
m_userSetWokingDirectory = false;
m_userWorkingDirectory = QString::null;
m_userWorkingDirectory.clear();
emit workingDirectoryChanged(workingDirectory());
} else {
m_userSetWokingDirectory = true;
......@@ -610,8 +610,8 @@ void Qt4RunConfiguration::updateTarget()
tr("Could not parse %1. The Qt4 run configuration %2 can not be started.")
.arg(m_proFilePath).arg(displayName()));
}
m_workingDir = QString::null;
m_executable = QString::null;
m_workingDir.clear();
m_executable.clear();
m_cachedTargetInformationValid = true;
emit effectiveTargetInformationChanged();
return;
......@@ -632,20 +632,16 @@ void Qt4RunConfiguration::invalidateCachedTargetInformation()
QString Qt4RunConfiguration::dumperLibrary() const
{
QtVersion *version = qt4Project()->activeQt4BuildConfiguration()->qtVersion();
if (version)
if (const QtVersion *version = qt4Project()->activeQt4BuildConfiguration()->qtVersion())
return version->debuggingHelperLibrary();
else
return QString::null;
return QString();
}
QStringList Qt4RunConfiguration::dumperLibraryLocations() const
{
QtVersion *version = qt4Project()->activeQt4BuildConfiguration()->qtVersion();
if (version)
if (const QtVersion *version = qt4Project()->activeQt4BuildConfiguration()->qtVersion())
return version->debuggingHelperLibraryLocations();
else
return QStringList();
return QStringList();
}
void Qt4RunConfiguration::setDefaultDisplayName()
......
......@@ -559,8 +559,7 @@ QtVersion::QtVersion(const QString &qmakeCommand, bool isAutodetected, const QSt
}
QtVersion::QtVersion()
: m_displayName(QString::null),
m_id(-1),
: m_id(-1),
m_isAutodetected(false),
m_hasDebuggingHelper(false),
m_toolChainUpToDate(false),
......@@ -572,7 +571,7 @@ QtVersion::QtVersion()
m_hasDemos(false),
m_hasDocumentation(false)
{
setQMakeCommand(QString::null);
setQMakeCommand(QString());
}
......@@ -666,7 +665,9 @@ void QtVersion::setQMakeCommand(const QString& qmakeCommand)
#ifdef Q_OS_WIN
m_qmakeCommand = m_qmakeCommand.toLower();
#endif
m_designerCommand = m_linguistCommand = m_uicCommand = QString::null;
m_designerCommand.clear();
m_linguistCommand.clear();
m_uicCommand.clear();
m_toolChainUpToDate = false;
// TODO do i need to optimize this?
m_versionInfoUpToDate = false;
......@@ -676,7 +677,7 @@ void QtVersion::setQMakeCommand(const QString& qmakeCommand)
if (qmake.exists() && qmake.isExecutable()) {
m_qtVersionString = DebuggingHelperLibrary::qtVersionForQMake(qmake.absoluteFilePath());
} else {
m_qtVersionString = QString::null;
m_qtVersionString.clear();
}
updateSourcePath();
}
......@@ -734,7 +735,7 @@ QString QtVersionManager::findQMakeBinaryFromMakefile(const QString &directory)
}
makefile.close();
}