diff options
author | Rohan McGovern <rohan.mcgovern@nokia.com> | 2009-04-22 23:06:43 (GMT) |
---|---|---|
committer | Rohan McGovern <rohan.mcgovern@nokia.com> | 2009-04-22 23:17:35 (GMT) |
commit | 7fa8e95d1b87403aab14dd326520600bc028a195 (patch) | |
tree | a3bd229bf67ae10b10b821bf3acb92b9da55a422 /src/svg/qsvgwidget.cpp | |
parent | e0dcc1dfec22f5625a363d8f207eb5bf061f6837 (diff) | |
download | Qt-7fa8e95d1b87403aab14dd326520600bc028a195.zip Qt-7fa8e95d1b87403aab14dd326520600bc028a195.tar.gz Qt-7fa8e95d1b87403aab14dd326520600bc028a195.tar.bz2 |
Fixes memory leak in QSvgWidget.
`q' is 0 during construction of QSvgWidgetPrivate, thus each
QSvgWidget instance was creating a QSvgRenderer with no parent.
Acked-by: Thiago Macieira
Reviewed-by: Shane Bradley
Diffstat (limited to 'src/svg/qsvgwidget.cpp')
-rw-r--r-- | src/svg/qsvgwidget.cpp | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/src/svg/qsvgwidget.cpp b/src/svg/qsvgwidget.cpp index a4200ca..ac8595f 100644 --- a/src/svg/qsvgwidget.cpp +++ b/src/svg/qsvgwidget.cpp @@ -83,18 +83,6 @@ class QSvgWidgetPrivate : public QWidgetPrivate { Q_DECLARE_PUBLIC(QSvgWidget) public: - QSvgWidgetPrivate() - : QWidgetPrivate() - { - Q_Q(QSvgWidget); - renderer = new QSvgRenderer(q); - } - QSvgWidgetPrivate(const QString &file) - : QWidgetPrivate() - { - Q_Q(QSvgWidget); - renderer = new QSvgRenderer(file, q); - } QSvgRenderer *renderer; }; @@ -104,6 +92,7 @@ public: QSvgWidget::QSvgWidget(QWidget *parent) : QWidget(*new QSvgWidgetPrivate, parent, 0) { + d_func()->renderer = new QSvgRenderer(this); QObject::connect(d_func()->renderer, SIGNAL(repaintNeeded()), this, SLOT(update())); } @@ -113,8 +102,9 @@ QSvgWidget::QSvgWidget(QWidget *parent) of the specified \a file. */ QSvgWidget::QSvgWidget(const QString &file, QWidget *parent) - : QWidget(*new QSvgWidgetPrivate(file), parent, 0) + : QWidget(*new QSvgWidgetPrivate, parent, 0) { + d_func()->renderer = new QSvgRenderer(file, this); QObject::connect(d_func()->renderer, SIGNAL(repaintNeeded()), this, SLOT(update())); } |