[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [digikam] core/libs/widgets/combo: fix memory leak reported by clang
From: Gilles Caulier <null () kde ! org>
Date: 2018-09-20 16:16:41
Message-ID: E1g31dB-0003mq-Ra () code ! kde ! org
[Download RAW message or body]
Git commit a4f3a69e987101758cb8aaeed1973d4632f01d3d by Gilles Caulier.
Committed on 20/09/2018 at 16:16.
Pushed by cgilles into branch 'master'.
fix memory leak reported by clang
M +19 -3 core/libs/widgets/combo/comboboxutilities.cpp
https://commits.kde.org/digikam/a4f3a69e987101758cb8aaeed1973d4632f01d3d
diff --git a/core/libs/widgets/combo/comboboxutilities.cpp \
b/core/libs/widgets/combo/comboboxutilities.cpp index 0c63a4d4e8..ed545f1a15 100644
--- a/core/libs/widgets/combo/comboboxutilities.cpp
+++ b/core/libs/widgets/combo/comboboxutilities.cpp
@@ -28,6 +28,7 @@
#include <QAbstractItemView>
#include <QAbstractListModel>
#include <QMouseEvent>
+#include <QPointer>
#include <QPainter>
#include <QPen>
#include <QStyle>
@@ -343,7 +344,15 @@ TreeViewComboBox::TreeViewComboBox(QWidget* const parent)
void TreeViewComboBox::installView(QAbstractItemView* view)
{
// parent does the heavy work
- StayPoppedUpComboBox::installView(view ? view : new TreeViewComboBoxTreeView);
+ if (view)
+ {
+ StayPoppedUpComboBox::installView(view);
+ }
+ else
+ {
+ QPointer<TreeViewComboBoxTreeView> tview = new TreeViewComboBoxTreeView;
+ StayPoppedUpComboBox::installView(tview);
+ }
}
void TreeViewComboBox::sendViewportEventToView(QEvent* e)
@@ -383,8 +392,15 @@ ListViewComboBox::ListViewComboBox(QWidget* const parent)
void ListViewComboBox::installView(QAbstractItemView* view)
{
// parent does the heavy work
- StayPoppedUpComboBox::installView(view ? view
- : new ListViewComboBoxListView);
+ if (view)
+ {
+ StayPoppedUpComboBox::installView(view);
+ }
+ else
+ {
+ QPointer<ListViewComboBoxListView> lview = new ListViewComboBoxListView;
+ StayPoppedUpComboBox::installView(lview);
+ }
}
void ListViewComboBox::sendViewportEventToView(QEvent* e)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic