From 6a7f5be0eae128eaa16c4459b81cda0302957e85 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Wed, 7 Dec 2022 18:18:48 +0100 Subject: [PATCH] PluginGenerator: Fix returning the error message I bet the original intention was to return a new message, so we should assing a new value into the passed pointer rather than change the local copy of a pointer so that it start pointing to the local variable. Amends aaa8beab88dddd7218f6d3c30fb29c04679e2098 Change-Id: I1fdc8f3f4ea43e4814f02dbf615ad128bfc9a059 Reviewed-by: Christian Kandeler --- .../customwidgetwizard/plugingenerator.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/plugins/qmakeprojectmanager/customwidgetwizard/plugingenerator.cpp b/src/plugins/qmakeprojectmanager/customwidgetwizard/plugingenerator.cpp index c3475fd1334..4795c77509f 100644 --- a/src/plugins/qmakeprojectmanager/customwidgetwizard/plugingenerator.cpp +++ b/src/plugins/qmakeprojectmanager/customwidgetwizard/plugingenerator.cpp @@ -295,20 +295,17 @@ QString PluginGenerator::processTemplate(const QString &tmpl, { Utils::FileReader reader; if (!reader.fetch(Utils::FilePath::fromString(tmpl), errorMessage)) - return QString(); - + return {}; 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()) { + cont = Utils::TemplateEngine::processText(expander, cont, errorMessage); + if (!errorMessage->isEmpty()) { qWarning("Error processing custom plugin file: %s\nFile:\n%s", - qPrintable(errMsg), qPrintable(cont)); - errorMessage = &errMsg; - return QString(); + qPrintable(*errorMessage), qPrintable(cont)); + return {}; } const QChar atChar = QLatin1Char('@');