forked from qt-creator/qt-creator
Avoid storing references to rvalue FileName strings
Following 73616849
, it is dangerous to store a reference to the rvalue of
toString(), since it might become dangling.
Example:
FileName foo() { return FileName::fromString(QLatin1String("/some/file")); }
void func()
{
const QString &fileName = foo().toString();
// fileName is now a dangling reference
}
Change-Id: I5dfad5dc8dd568a0a3c8f9f71ad93292dc26cbbe
Reviewed-by: hjk <hjk@theqtcompany.com>
This commit is contained in:
@@ -1662,7 +1662,7 @@ bool EditorManagerPrivate::saveDocument(IDocument *document)
|
|||||||
|
|
||||||
document->checkPermissions();
|
document->checkPermissions();
|
||||||
|
|
||||||
const QString &fileName = document->filePath().toString();
|
const QString fileName = document->filePath().toString();
|
||||||
|
|
||||||
if (fileName.isEmpty())
|
if (fileName.isEmpty())
|
||||||
return saveDocumentAs(document);
|
return saveDocumentAs(document);
|
||||||
|
@@ -490,7 +490,7 @@ QStringList SessionManagerPrivate::dependenciesOrder() const
|
|||||||
|
|
||||||
// copy the map to a temporary list
|
// copy the map to a temporary list
|
||||||
foreach (Project *pro, m_projects) {
|
foreach (Project *pro, m_projects) {
|
||||||
const QString &proName = pro->projectFilePath().toString();
|
const QString proName = pro->projectFilePath().toString();
|
||||||
unordered << QPair<QString, QStringList>(proName, m_depMap.value(proName));
|
unordered << QPair<QString, QStringList>(proName, m_depMap.value(proName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -7201,7 +7201,7 @@ void TextEditorWidget::configureGenericHighlighter()
|
|||||||
setCodeFoldingSupported(true);
|
setCodeFoldingSupported(true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const QString &fileName = textDocument()->filePath().toString();
|
const QString fileName = textDocument()->filePath().toString();
|
||||||
if (TextEditorSettings::highlighterSettings().isIgnoredFilePattern(fileName))
|
if (TextEditorSettings::highlighterSettings().isIgnoredFilePattern(fileName))
|
||||||
d->m_isMissingSyntaxDefinition = false;
|
d->m_isMissingSyntaxDefinition = false;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user