diff --git a/src/shared/Modules/CommandPad/CommandPad.cpp b/src/shared/Modules/CommandPad/CommandPad.cpp index 85e8d638f169e68e0b491fab7a1cc461682b4bd5..78e950495d7413ba3ab4e7179da0a5ca11388b2f 100644 --- a/src/shared/Modules/CommandPad/CommandPad.cpp +++ b/src/shared/Modules/CommandPad/CommandPad.cpp @@ -24,12 +24,7 @@ CommandPad::CommandPad() : Module(ModuleId::COMMAND_PAD) { setupUi(); } -CommandPad::~CommandPad() -{ - delete messagesListComboBox; - for (auto key : formElements.keys()) - delete formElements[key]; -} +CommandPad::~CommandPad() {} XmlObject CommandPad::toXmlObject() { @@ -61,11 +56,11 @@ void CommandPad::setupUi() QVBoxLayout *outerLayout = new QVBoxLayout; outerLayout->addStretch(); - messagesListComboBox = new QComboBox; + messagesListComboBox = std::make_unique<QComboBox>(); messagesListComboBox->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); messagesListComboBox->addItems(MessagesList::messagesList); - outerLayout->addWidget(messagesListComboBox); + outerLayout->addWidget(messagesListComboBox.get()); QGridLayout *formGridLayout = new QGridLayout; outerLayout->addLayout(formGridLayout); @@ -81,7 +76,7 @@ void CommandPad::setupUi() currentMessage = "PING_TC"; messagesListComboBox->setCurrentText(currentMessage); - connect(messagesListComboBox, &QComboBox::currentTextChanged, this, + connect(messagesListComboBox.get(), &QComboBox::currentTextChanged, this, [=](QString key) { if (formElements.contains(key)) diff --git a/src/shared/Modules/CommandPad/CommandPad.h b/src/shared/Modules/CommandPad/CommandPad.h index ec9e24502a53ec03a257cc196970ab4a9ec8c515..e1f03a8333623093ad34893c334753db9d398dbf 100644 --- a/src/shared/Modules/CommandPad/CommandPad.h +++ b/src/shared/Modules/CommandPad/CommandPad.h @@ -38,6 +38,6 @@ private: void setupUi(); QString currentMessage; - QComboBox* messagesListComboBox; - QMap<QString, MessageFormElement*> formElements; + std::unique_ptr<QComboBox> messagesListComboBox; + QMap<QString, std::unique_ptr<MessageFormElement>> formElements; };