summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools/cppprojects.cpp
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@theqtcompany.com>2015-01-27 10:07:54 +0100
committerChristian Kandeler <christian.kandeler@theqtcompany.com>2015-01-27 15:25:23 +0000
commite7a18108e1bf6f3f5959a72a8229449cf4ea6a2b (patch)
tree456308878c563132a2f0a431b1d7fcc00b0d7dc8 /src/plugins/cpptools/cppprojects.cpp
parent56637a5d254cec7d5faf0bd0d5fa4f628c1a25cd (diff)
downloadqt-creator-e7a18108e1bf6f3f5959a72a8229449cf4ea6a2b.tar.gz
CppTools: Fix macro collection.
"#define XYZ" does not correspond to "-DXYZ" (which means "#define XYZ 1"), but to "-DXYZ=". Change-Id: I3ed44e1457b3df52dc9bdb930ba8f4a04784d207 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
Diffstat (limited to 'src/plugins/cpptools/cppprojects.cpp')
-rw-r--r--src/plugins/cpptools/cppprojects.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/plugins/cpptools/cppprojects.cpp b/src/plugins/cpptools/cppprojects.cpp
index 215279825b..c708a98b88 100644
--- a/src/plugins/cpptools/cppprojects.cpp
+++ b/src/plugins/cpptools/cppprojects.cpp
@@ -511,7 +511,6 @@ QStringList CompilerOptionsBuilder::createDefineOptions(const QByteArray &define
const QString &toolchainType)
{
QStringList result;
- const QString option = QLatin1String(toolchainType == QLatin1String("msvc") ? "/D" : "-D");
foreach (QByteArray def, defines.split('\n')) {
if (def.isEmpty())
@@ -535,12 +534,11 @@ QStringList CompilerOptionsBuilder::createDefineOptions(const QByteArray &define
QByteArray str = def.mid(8);
int spaceIdx = str.indexOf(' ');
- QString arg;
- if (spaceIdx != -1) {
- arg = option + QLatin1String(str.left(spaceIdx) + "=" + str.mid(spaceIdx + 1));
- } else {
- arg = option + QLatin1String(str);
- }
+ const QString option = QLatin1String(toolchainType == QLatin1String("msvc") ? "/D" : "-D");
+ const bool hasValue = spaceIdx != -1;
+ QString arg = option + QLatin1String(str.left(hasValue ? spaceIdx : str.size()) + '=');
+ if (hasValue)
+ arg += QLatin1String(str.mid(spaceIdx + 1));
arg = arg.replace(QLatin1String("\\\""), QLatin1String("\""));
arg = arg.replace(QLatin1String("\""), QLatin1String(""));
if (!result.contains(arg))