clang-tidy: Avoid another warning about potential memory leak
authorManuel Nickschas <sputnick@quassel-irc.org>
Wed, 5 Sep 2018 18:53:24 +0000 (20:53 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Thu, 6 Sep 2018 06:02:07 +0000 (08:02 +0200)
This is a false positive (since the newly created QFormLayout takes
a widget as its parent), however some slight rearrangement of
code shuts up clang-tidy without resorting to NOLINT.

src/qtui/coreconfigwizard.cpp

index 471837b..8225fe4 100644 (file)
@@ -54,10 +54,11 @@ QGroupBox *createFieldBox(const QString &title, const std::vector<FieldInfo> &fi
     // provide specialized config widgets for those (which may be a good idea anyway, e.g. if we
     // think about client-side translations...)
 
-    QGroupBox *fieldBox = new QGroupBox;
+    auto *fieldBox = new QGroupBox;
     fieldBox->setTitle(title);
+    auto *formLayout = new QFormLayout;
+    fieldBox->setLayout(formLayout);
 
-    QFormLayout *formLayout = new QFormLayout(fieldBox);
     for (auto &&fieldInfo : fieldInfos) {
         QWidget *widget {nullptr};
         switch (std::get<2>(fieldInfo).type()) {