Remove unused variables

Mark some of them with Q_UNUSED, since it looks like
sometimes the copy is done on purpose, to force detach
or used for some hack with memory management.
In one case make unused variable used again.

Change-Id: I3825cd3399fa63bf6e12173c64509287d4a125e5
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Jarek Kobus
2020-11-18 14:30:03 +01:00
parent 06bc4203cf
commit 6b588d7227
20 changed files with 5 additions and 22 deletions

View File

@@ -854,8 +854,6 @@ void AndroidManifestEditorWidget::syncToWidgets(const QDomDocument &doc)
setApiLevel(m_androidTargetSdkVersion, usesSdkElement, QLatin1String("android:targetSdkVersion")); setApiLevel(m_androidTargetSdkVersion, usesSdkElement, QLatin1String("android:targetSdkVersion"));
} }
QString baseDir = m_textEditorWidget->textDocument()->filePath().toFileInfo().absolutePath();
QDomElement applicationElement = manifest.firstChildElement(QLatin1String("application")); QDomElement applicationElement = manifest.firstChildElement(QLatin1String("application"));
m_appNameLineEdit->setText(applicationElement.attribute(QLatin1String("android:label"))); m_appNameLineEdit->setText(applicationElement.attribute(QLatin1String("android:label")));

View File

@@ -146,7 +146,6 @@ void AvdDialog::parseDeviceDefinitionsList()
if (line.startsWith("---------") || line.isEmpty()) { if (line.startsWith("---------") || line.isEmpty()) {
DeviceDefinitionStruct deviceDefinition; DeviceDefinitionStruct deviceDefinition;
for (const QString &line : avdDeviceInfo) { for (const QString &line : avdDeviceInfo) {
QString value;
if (line.contains("id:")) { if (line.contains("id:")) {
deviceDefinition.name_id = line.split("or").at(1); deviceDefinition.name_id = line.split("or").at(1);
deviceDefinition.name_id = deviceDefinition.name_id.remove(0, 1).remove('"'); deviceDefinition.name_id = deviceDefinition.name_id.remove(0, 1).remove('"');

View File

@@ -568,7 +568,6 @@ void TestRunner::debugTests()
return; return;
} }
QString errorMessage;
auto runControl = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE); auto runControl = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE);
runControl->setRunConfiguration(config->runConfiguration()); runControl->setRunConfiguration(config->runConfiguration());

View File

@@ -74,6 +74,7 @@ void QdbMakeDefaultAppService::handleProcessFinished(const QString &error)
return; return;
} }
// FIXME: Check that ignoring is fine
QByteArray processOutput = d->processRunner->readAllStandardOutput(); QByteArray processOutput = d->processRunner->readAllStandardOutput();
if (d->makeDefault) if (d->makeDefault)

View File

@@ -381,7 +381,6 @@ void ClangToolRunWorker::onRunnerFinishedWithFailure(const QString &errorMessage
auto *toolRunner = qobject_cast<ClangToolRunner *>(sender()); auto *toolRunner = qobject_cast<ClangToolRunner *>(sender());
const QString fileToAnalyze = toolRunner->fileToAnalyze(); const QString fileToAnalyze = toolRunner->fileToAnalyze();
const QString outputFilePath = toolRunner->outputFilePath();
m_filesAnalyzed.remove(fileToAnalyze); m_filesAnalyzed.remove(fileToAnalyze);
m_filesNotAnalyzed.insert(fileToAnalyze); m_filesNotAnalyzed.insert(fileToAnalyze);

View File

@@ -466,7 +466,6 @@ void addCompileGroups(ProjectNode *targetRoot,
QSet<FilePath> &knownHeaderNodes) QSet<FilePath> &knownHeaderNodes)
{ {
const bool inSourceBuild = (sourceDirectory == buildDirectory); const bool inSourceBuild = (sourceDirectory == buildDirectory);
const QDir currentSourceDir(sourceDirectory.toString());
std::vector<std::unique_ptr<FileNode>> toList; std::vector<std::unique_ptr<FileNode>> toList;
QSet<Utils::FilePath> alreadyListed; QSet<Utils::FilePath> alreadyListed;

View File

@@ -1058,7 +1058,6 @@ QList<ToolChain *> GccToolChainFactory::autoDetect(const QList<ToolChain *> &alr
if (HostOsInfo::isMacHost()) if (HostOsInfo::isMacHost())
return {}; return {};
QList<ToolChain *> tcs; QList<ToolChain *> tcs;
QList<ToolChain *> known = alreadyKnown;
static const auto tcChecker = [](const ToolChain *tc) { static const auto tcChecker = [](const ToolChain *tc) {
return tc->targetAbi().osFlavor() != Abi::WindowsMSysFlavor return tc->targetAbi().osFlavor() != Abi::WindowsMSysFlavor
&& tc->compilerCommand().fileName() != "c89-gcc" && tc->compilerCommand().fileName() != "c89-gcc"

View File

@@ -636,7 +636,6 @@ void LineEditField::setupCompletion(FancyLineEdit *lineEdit)
const auto handleResults = [this, lineEdit, watcher](int firstIndex, int endIndex) { const auto handleResults = [this, lineEdit, watcher](int firstIndex, int endIndex) {
QSet<QString> namespaces; QSet<QString> namespaces;
QStringList classes; QStringList classes;
QString projectBaseDir;
Project * const project = ProjectTree::currentProject(); Project * const project = ProjectTree::currentProject();
for (int i = firstIndex; i < endIndex; ++i) { for (int i = firstIndex; i < endIndex; ++i) {
static const auto isReservedName = [](const QString &name) { static const auto isReservedName = [](const QString &name) {

View File

@@ -542,7 +542,6 @@ JsonWizardJsExtension::JsonWizardJsExtension(JsonWizard *wizard)
QVariant JsonWizardJsExtension::value(const QString &name) const QVariant JsonWizardJsExtension::value(const QString &name) const
{ {
const QVariant value = m_wizard->value(name);
return m_wizard->expander()->expandVariant(m_wizard->value(name)); return m_wizard->expander()->expandVariant(m_wizard->value(name));
} }

View File

@@ -396,7 +396,6 @@ public:
{ {
Kit *kit = KitManager::kit(m_kitId); Kit *kit = KitManager::kit(m_kitId);
QTC_ASSERT(kit, return); QTC_ASSERT(kit, return);
const QString kitName = kit->displayName();
const QString projectName = m_project->displayName(); const QString projectName = m_project->displayName();
QAction *enableAction = menu->addAction(tr("Enable Kit for Project \"%1\"").arg(projectName)); QAction *enableAction = menu->addAction(tr("Enable Kit for Project \"%1\"").arg(projectName));

View File

@@ -45,7 +45,7 @@ void findQmlFiles(QFutureInterface<Utils::FilePath> &f, const Project *project)
return; return;
int index = 0; int index = 0;
Utils::FilePaths qmlFiles = project->files([&f, &index](const Node* node) ->bool { project->files([&f, &index](const Node* node) ->bool {
if (f.isCanceled()) if (f.isCanceled())
return false; return false;
Utils::FilePath path = node->filePath(); Utils::FilePath path = node->filePath();

View File

@@ -54,7 +54,6 @@ QJsonObject AssetNodeParser::json(Component &component) const
{ {
QJsonObject jsonObject = ItemNodeParser::json(component); QJsonObject jsonObject = ItemNodeParser::json(component);
QPixmap asset = objectNode().toQmlItemNode().instanceRenderPixmap();
Utils::FilePath assetPath = component.exporter().exportAsset(objectNode(), uuid()); Utils::FilePath assetPath = component.exporter().exportAsset(objectNode(), uuid());
QJsonObject assetData; QJsonObject assetData;
assetData.insert(AssetPathTag, assetPath.toString()); assetData.insert(AssetPathTag, assetPath.toString());

View File

@@ -523,7 +523,6 @@ QStringList ConnectionModel::getPossibleSignalsForConnection(const ModelNode &co
const BindingProperty bp = connection.bindingProperty("target"); const BindingProperty bp = connection.bindingProperty("target");
if (bp.isValid()) { if (bp.isValid()) {
const QString bindExpression = bp.expression();
QStringList expression = bp.expression().split("."); QStringList expression = bp.expression().split(".");
if (expression.size() > 1) { if (expression.size() > 1) {
const QString itemId = expression.constFirst(); const QString itemId = expression.constFirst();

View File

@@ -535,7 +535,6 @@ void ConnectionViewWidget::editorForDynamic()
VariantProperty property = abProp.toVariantProperty(); VariantProperty property = abProp.toVariantProperty();
PropertyName name = property.name(); PropertyName name = property.name();
TypeName type = property.dynamicTypeName(); TypeName type = property.dynamicTypeName();
QVariant value = newValue;
BindingProperty newProperty = propertiesModel BindingProperty newProperty = propertiesModel
->replaceVariantWithBinding(name); ->replaceVariantWithBinding(name);

View File

@@ -238,7 +238,6 @@ void ItemLibraryAssetImporter::parseFiles(const QStringList &filePaths,
if (isCancelled()) if (isCancelled())
return; return;
if (isQuick3DAsset(file)) { if (isQuick3DAsset(file)) {
QVariantMap varOpts;
int index = extToImportOptionsMap.value(QFileInfo(file).suffix()); int index = extToImportOptionsMap.value(QFileInfo(file).suffix());
parseQuick3DAsset(file, options[index].toVariantMap()); parseQuick3DAsset(file, options[index].toVariantMap());
} }
@@ -383,7 +382,6 @@ void ItemLibraryAssetImporter::parseQuick3DAsset(const QString &file, const QVar
out << "canBeDroppedInView3D: true" << Qt::endl; out << "canBeDroppedInView3D: true" << Qt::endl;
file.close(); file.close();
} }
QString outIconSource = QString::fromUtf8(content);
if (generateComponentIcon(24, iconFileName, qmlIt.filePath())) { if (generateComponentIcon(24, iconFileName, qmlIt.filePath())) {
// Since icon is generated by external process, the file won't be // Since icon is generated by external process, the file won't be
// ready for asset gathering below, so assume its generation succeeds // ready for asset gathering below, so assume its generation succeeds

View File

@@ -658,7 +658,7 @@ void RichTextEditor::setupTableActions()
m_actionSplitRow->setCheckable(false); m_actionSplitRow->setCheckable(false);
const QIcon splitColumnIcon(getIcon(Theme::Icon::splitColumns)); const QIcon splitColumnIcon(getIcon(Theme::Icon::splitColumns));
m_actionSplitColumn = ui->tableBar->addAction(splitRowIcon, tr("Split Column"), [this]() { m_actionSplitColumn = ui->tableBar->addAction(splitColumnIcon, tr("Split Column"), [this]() {
QTextCursor cursor = ui->textEdit->textCursor(); QTextCursor cursor = ui->textEdit->textCursor();
if (QTextTable *currentTable = cursor.currentTable()) { if (QTextTable *currentTable = cursor.currentTable()) {
cursorEditBlock(cursor, [&] () { cursorEditBlock(cursor, [&] () {

View File

@@ -413,8 +413,6 @@ QString QmlDebugTranslationWidget::currentDir() const
void QmlDebugTranslationWidget::setCurrentDir(const QString &path) void QmlDebugTranslationWidget::setCurrentDir(const QString &path)
{ {
m_lastDir = path; m_lastDir = path;
const QString currentDir = m_lastDir.isEmpty() ?
ProjectExplorer::ProjectTree::currentFilePath().parentDir().toString() : m_lastDir;
} }
void QmlDebugTranslationWidget::loadLogFile() void QmlDebugTranslationWidget::loadLogFile()

View File

@@ -142,9 +142,6 @@ LocalQmlPreviewSupport::LocalQmlPreviewSupport(ProjectExplorer::RunControl *runC
const QString mainScriptFromProject = qmlBuildSystem->targetFile( const QString mainScriptFromProject = qmlBuildSystem->targetFile(
Utils::FilePath::fromString(mainScript)).toString(); Utils::FilePath::fromString(mainScript)).toString();
const QString currentFileFromProject = qmlBuildSystem->targetFile(
Utils::FilePath::fromString(currentFile)).toString();
if (!currentFile.isEmpty() && qmlProjectRunConfigurationArguments.last().contains(mainScriptFromProject)) { if (!currentFile.isEmpty() && qmlProjectRunConfigurationArguments.last().contains(mainScriptFromProject)) {
qmlProjectRunConfigurationArguments.removeLast(); qmlProjectRunConfigurationArguments.removeLast();
auto commandLine = Utils::CommandLine(runnable.commandLine().executable(), qmlProjectRunConfigurationArguments); auto commandLine = Utils::CommandLine(runnable.commandLine().executable(), qmlProjectRunConfigurationArguments);

View File

@@ -824,6 +824,7 @@ void MemcheckToolPrivate::heobAction()
if (!commandLineArguments.isEmpty()) if (!commandLineArguments.isEmpty())
arguments += ' ' + commandLineArguments; arguments += ' ' + commandLineArguments;
QByteArray argumentsCopy(reinterpret_cast<const char *>(arguments.utf16()), arguments.size() * 2 + 2); QByteArray argumentsCopy(reinterpret_cast<const char *>(arguments.utf16()), arguments.size() * 2 + 2);
Q_UNUSED(argumentsCopy)
// process environment // process environment
QByteArray env; QByteArray env;

View File

@@ -1143,6 +1143,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
for (const ProString &val : vals) { for (const ProString &val : vals) {
QString rstr = val.toQString(m_tmp1); QString rstr = val.toQString(m_tmp1);
QString copy = rstr; // Force a detach on modify QString copy = rstr; // Force a detach on modify
Q_UNUSED(copy)
rstr.replace(before, after); rstr.replace(before, after);
ret << (rstr.isSharedWith(m_tmp1) ret << (rstr.isSharedWith(m_tmp1)
? val ? val