aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorMikael Kanstrup <mikael.kanstrup@gmail.com>2017-09-18 15:22:18 +0200
committerAnders Broman <a.broman58@gmail.com>2017-09-19 06:44:08 +0000
commit8a25ac7306b9eef5c7d75ee1c610eb2b0a8144fe (patch)
treeb499783b053f220700029e601997d7f803046f75 /ui
parent16fc1903037dead72d5f6ff1457552d23b4a423f (diff)
qt: Fix leaked style for OverlayScrollBar
The QWidget::setStyle method does not transfer ownership of supplied style object. Fix leak by letting OverlayScrollBar free styles created. Bug: 14071 Change-Id: Ibc14cadfc6d012e8a909be21b4f8974009fa75f5 Reviewed-on: https://code.wireshark.org/review/23601 Reviewed-by: Michael Mann <mmann78@netscape.net> Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ui')
-rw-r--r--ui/qt/widgets/overlay_scroll_bar.cpp13
-rw-r--r--ui/qt/widgets/overlay_scroll_bar.h4
2 files changed, 14 insertions, 3 deletions
diff --git a/ui/qt/widgets/overlay_scroll_bar.cpp b/ui/qt/widgets/overlay_scroll_bar.cpp
index 68f1ba0f56..73a291b058 100644
--- a/ui/qt/widgets/overlay_scroll_bar.cpp
+++ b/ui/qt/widgets/overlay_scroll_bar.cpp
@@ -25,7 +25,6 @@
#include <QMouseEvent>
#include <QPainter>
-#include <QProxyStyle>
#include <QResizeEvent>
#include <QStyleOptionSlider>
@@ -81,11 +80,13 @@ OverlayScrollBar::OverlayScrollBar(Qt::Orientation orientation, QWidget *parent)
end_pos_(-1),
selected_pos_(-1)
{
- setStyle(new OsbProxyStyle);
+ style_ = new OsbProxyStyle();
+ setStyle(style_);
+ child_style_ = new OsbProxyStyle();
child_sb_.raise();
child_sb_.installEventFilter(this);
- child_sb_.setStyle(new OsbProxyStyle);
+ child_sb_.setStyle(child_style_);
// XXX Do we need to connect anything else?
connect(this, SIGNAL(rangeChanged(int,int)), this, SLOT(setChildRange(int,int)));
@@ -94,6 +95,12 @@ OverlayScrollBar::OverlayScrollBar(Qt::Orientation orientation, QWidget *parent)
connect(&child_sb_, SIGNAL(valueChanged(int)), this, SLOT(setValue(int)));
}
+OverlayScrollBar::~OverlayScrollBar()
+{
+ delete child_style_;
+ delete style_;
+}
+
QSize OverlayScrollBar::sizeHint() const
{
return QSize(packet_map_width_ + child_sb_.sizeHint().width(),
diff --git a/ui/qt/widgets/overlay_scroll_bar.h b/ui/qt/widgets/overlay_scroll_bar.h
index c6d2909f32..dd3624ac66 100644
--- a/ui/qt/widgets/overlay_scroll_bar.h
+++ b/ui/qt/widgets/overlay_scroll_bar.h
@@ -23,6 +23,7 @@
#define __OVERLAY_SCROLL_BAR_H__
#include <QScrollBar>
+#include <QProxyStyle>
class OverlayScrollBar : public QScrollBar
{
@@ -30,6 +31,7 @@ class OverlayScrollBar : public QScrollBar
public:
OverlayScrollBar(Qt::Orientation orientation, QWidget * parent = 0);
+ virtual ~OverlayScrollBar();
virtual QSize sizeHint() const;
@@ -72,6 +74,8 @@ protected:
virtual void mouseReleaseEvent(QMouseEvent * event);
private:
+ QProxyStyle* style_;
+ QProxyStyle* child_style_;
QScrollBar child_sb_;
QImage packet_map_img_;
QImage marked_packet_img_;