From 5b53ed07bf2c9000c1740b2fcbe00ef2850742bb Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Sun, 1 May 2022 17:07:29 +0300
Subject: [PATCH 58/58] Qt: Avoid option_dialog::add_option() using NULL object
 pointer

See osdn #44484

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 client/gui-qt/optiondlg.cpp | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/client/gui-qt/optiondlg.cpp b/client/gui-qt/optiondlg.cpp
index 65ed249d32..9b5305d9ab 100644
--- a/client/gui-qt/optiondlg.cpp
+++ b/client/gui-qt/optiondlg.cpp
@@ -634,7 +634,7 @@ void option_dialog::add_option(struct option *poption)
   unsigned int j;
 
   category_name = option_category_name(poption);
-  widget = NULL;
+  widget = nullptr;
 
   if (!categories.contains(category_name)) {
     twidget = new QWidget();
@@ -744,7 +744,7 @@ void option_dialog::add_option(struct option *poption)
     break;
   }
 
-  if (widget != NULL) {
+  if (widget != nullptr) {
     hbox_layout = new QHBoxLayout();
     hbox_layout->setAlignment(Qt::AlignRight);
     label = new QLabel(description);
@@ -756,11 +756,12 @@ void option_dialog::add_option(struct option *poption)
     lwidget->setLayout(hbox_layout);
     twidget_layout = qobject_cast < QVBoxLayout * >(twidget->layout());
     twidget_layout->addWidget(lwidget);
+
+    widget->setEnabled(option_is_changeable(poption));
+    widget->setToolTip(split_text(option_help_text(poption), false));
   }
 
-  widget->setEnabled(option_is_changeable(poption));
-  widget->setToolTip(split_text(option_help_text(poption), false));
-  option_set_gui_data(poption, widget);
+  option_set_gui_data(poption, widget); // May set nullptr as the gui_data
   option_dialog_refresh(poption);
 }
 
-- 
2.35.1