summaryrefslogtreecommitdiff
path: root/src/plugins/qmakeprojectmanager/customwidgetwizard
diff options
context:
space:
mode:
authorFilip Bucek <fbucek@atlas.cz>2019-01-03 10:56:36 +0100
committerFilip Bucek <fbucek@atlas.cz>2019-01-23 09:10:42 +0000
commitaaa8beab88dddd7218f6d3c30fb29c04679e2098 (patch)
treeb6416714fee6923386c87b0b29f72a6bccecf90e /src/plugins/qmakeprojectmanager/customwidgetwizard
parent2781c2a9004f1404580c287364e10add20bcb180 (diff)
downloadqt-creator-aaa8beab88dddd7218f6d3c30fb29c04679e2098.tar.gz
Wizards: Support using #pragma once instead of include guards
Allow users to choose #pragma once instead of #ifndef include guards in generated header files. Fixes: QTCREATORBUG-12166 Change-Id: I3ba41c7570beb9c5958e174b5581fcc25855050f Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Filip Bucek <fbucek@atlas.cz>
Diffstat (limited to 'src/plugins/qmakeprojectmanager/customwidgetwizard')
-rw-r--r--src/plugins/qmakeprojectmanager/customwidgetwizard/plugingenerator.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/plugins/qmakeprojectmanager/customwidgetwizard/plugingenerator.cpp b/src/plugins/qmakeprojectmanager/customwidgetwizard/plugingenerator.cpp
index f43b4ca73e..be08ea5ff2 100644
--- a/src/plugins/qmakeprojectmanager/customwidgetwizard/plugingenerator.cpp
+++ b/src/plugins/qmakeprojectmanager/customwidgetwizard/plugingenerator.cpp
@@ -30,6 +30,8 @@
#include <cpptools/abstracteditorsupport.h>
#include <utils/fileutils.h>
+#include <utils/macroexpander.h>
+#include <utils/templateengine.h>
#include <QFileInfo>
#include <QDir>
@@ -311,7 +313,20 @@ QString PluginGenerator::processTemplate(const QString &tmpl,
if (!reader.fetch(tmpl, errorMessage))
return QString();
+
QString cont = QString::fromUtf8(reader.data());
+
+ // Expander needed to handle extra variable "Cpp:PragmaOnce"
+ Utils::MacroExpander *expander = Utils::globalMacroExpander();
+ QString errMsg;
+ cont = Utils::TemplateEngine::processText(expander, cont, &errMsg);
+ if (!errMsg.isEmpty()) {
+ qWarning("Error processing custom plugin file: %s\nFile:\n%s",
+ qPrintable(errMsg), qPrintable(cont));
+ errorMessage = &errMsg;
+ return QString();
+ }
+
const QChar atChar = QLatin1Char('@');
int offset = 0;
for (;;) {