From 335dff53af63d798db70921c5b09bb230849da33 Mon Sep 17 00:00:00 2001 From: nerix Date: Sat, 10 Jun 2023 12:55:47 +0200 Subject: [PATCH] Don't add QLayouts to QWidgets that already have one (#4672) --- CHANGELOG.md | 1 + src/widgets/Window.cpp | 2 +- src/widgets/dialogs/EmotePopup.cpp | 4 ++-- src/widgets/helper/EditableModelView.cpp | 2 +- src/widgets/helper/SearchPopup.cpp | 2 +- src/widgets/splits/Split.cpp | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eaeb94f5..285c736a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - Dev: Added tools to help debug image GC. (#4578) - Dev: Removed duplicate license when having plugins enabled. (#4665) - Dev: Replace our QObjectRef class with Qt's QPointer class. (#4666) +- Dev: Fixed warnings about QWidgets already having a QLayout. (#4672) - Dev: Fixed undefined behavior when loading non-existant credentials. (#4673) ## 2.4.4 diff --git a/src/widgets/Window.cpp b/src/widgets/Window.cpp index 12f60583..efcd33d4 100644 --- a/src/widgets/Window.cpp +++ b/src/widgets/Window.cpp @@ -152,7 +152,7 @@ void Window::closeEvent(QCloseEvent *) void Window::addLayout() { - QVBoxLayout *layout = new QVBoxLayout(this); + auto *layout = new QVBoxLayout(); layout->addWidget(this->notebook_); this->getLayoutContainer()->setLayout(layout); diff --git a/src/widgets/dialogs/EmotePopup.cpp b/src/widgets/dialogs/EmotePopup.cpp index c81abd04..8a096e27 100644 --- a/src/widgets/dialogs/EmotePopup.cpp +++ b/src/widgets/dialogs/EmotePopup.cpp @@ -209,7 +209,7 @@ EmotePopup::EmotePopup(QWidget *parent) this->setStayInScreenRect(true); this->moveTo(this, getApp()->windows->emotePopupPos(), false); - auto *layout = new QVBoxLayout(this); + auto *layout = new QVBoxLayout(); this->getLayoutContainer()->setLayout(layout); QRegularExpression searchRegex("\\S*"); @@ -218,7 +218,7 @@ EmotePopup::EmotePopup(QWidget *parent) layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); - auto *layout2 = new QHBoxLayout(this); + auto *layout2 = new QHBoxLayout(); layout2->setContentsMargins(8, 8, 8, 8); layout2->setSpacing(8); diff --git a/src/widgets/helper/EditableModelView.cpp b/src/widgets/helper/EditableModelView.cpp index 649f8577..97c6840b 100644 --- a/src/widgets/helper/EditableModelView.cpp +++ b/src/widgets/helper/EditableModelView.cpp @@ -32,7 +32,7 @@ EditableModelView::EditableModelView(QAbstractTableModel *model, bool movable) vbox->setContentsMargins(0, 0, 0, 0); // create button layout - QHBoxLayout *buttons = new QHBoxLayout(this); + auto *buttons = new QHBoxLayout(); this->buttons_ = buttons; vbox->addLayout(buttons); diff --git a/src/widgets/helper/SearchPopup.cpp b/src/widgets/helper/SearchPopup.cpp index 7879e3b9..6f0f5511 100644 --- a/src/widgets/helper/SearchPopup.cpp +++ b/src/widgets/helper/SearchPopup.cpp @@ -280,7 +280,7 @@ void SearchPopup::initLayout() // HBOX { - auto *layout2 = new QHBoxLayout(this); + auto *layout2 = new QHBoxLayout(); layout2->setContentsMargins(8, 8, 8, 8); layout2->setSpacing(8); diff --git a/src/widgets/splits/Split.cpp b/src/widgets/splits/Split.cpp index a6ae50da..5b9941ef 100644 --- a/src/widgets/splits/Split.cpp +++ b/src/widgets/splits/Split.cpp @@ -1124,7 +1124,7 @@ void Split::showViewerList() viewerDock->move(0, this->header_->height()); auto multiWidget = new QWidget(viewerDock); - auto dockVbox = new QVBoxLayout(viewerDock); + auto *dockVbox = new QVBoxLayout(); auto searchBar = new QLineEdit(viewerDock); auto chattersList = new QListWidget();