summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools/cppfindreferences.cpp
diff options
context:
space:
mode:
authorAndre Hartmann <aha_1980@gmx.de>2012-03-18 19:58:29 +0100
committerErik Verbruggen <erik.verbruggen@nokia.com>2012-03-29 14:34:39 +0200
commit3dec48557a2b9ff64237d2aa4077c65a62c6af42 (patch)
treed0d36d6c01ac6beb2b45b640fa8a26c9e6a6e53e /src/plugins/cpptools/cppfindreferences.cpp
parent60db5736604583fe99dde3c25412d97f9b77489d (diff)
downloadqt-creator-3dec48557a2b9ff64237d2aa4077c65a62c6af42.tar.gz
Fix C++ Macro Usages when Definition contains Newline.
Now truncates the displayed line at the first Newline character after the Macro name. Task-number: QTCREATORBUG-7113 Change-Id: Ifb13c01d10b97098b54ac4346a80f0dcff3a35f3 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Erik Verbruggen <erik.verbruggen@nokia.com>
Diffstat (limited to 'src/plugins/cpptools/cppfindreferences.cpp')
-rw-r--r--src/plugins/cpptools/cppfindreferences.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/plugins/cpptools/cppfindreferences.cpp b/src/plugins/cpptools/cppfindreferences.cpp
index 91676c6333..2182f7c851 100644
--- a/src/plugins/cpptools/cppfindreferences.cpp
+++ b/src/plugins/cpptools/cppfindreferences.cpp
@@ -646,9 +646,14 @@ void CppFindReferences::findMacroUses(const Macro &macro)
{
// ### FIXME: Encoding?
const QByteArray &source = getSource(macro.fileName(), workingCopy).toLatin1();
- const QByteArray line = source.mid(macro.offset(), macro.length());
+ QByteArray line = source.mid(macro.offset(), macro.length());
+ const int macroNameOffset = line.indexOf(macro.name());
+ const int macroNameLength = macro.name().length();
+ const int possibleNewLine = line.indexOf('\n', macroNameOffset + macroNameLength);
+ if (possibleNewLine != -1)
+ line.truncate(possibleNewLine); // truncate line at first '\n' after macro name
search->addResult(macro.fileName(), macro.line(), line,
- line.indexOf(macro.name()), macro.name().length());
+ macroNameOffset, macroNameLength);
}
QFuture<Usage> result;