diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2014-07-20 16:46:28 +0200 |
---|---|---|
committer | Holger Freyther <holger+qt@freyther.de> | 2014-07-21 08:05:57 +0200 |
commit | 23e506fb3ea393e6ed1698923094000d6b640dac (patch) | |
tree | 2c3df8c112771d3292e19f2df35debd877fbc9ad /src/qml/qml | |
parent | a62955472b2acd644db46ea194d4fb0bc119150f (diff) |
qml: Fix potential memory leak in the file selector
The myInstance doesn't seem to be part of a QObject parent/child
relationship and Coverity complained about it. Use a QScopedPointer
to make sure the data will be deleted.
Fixes: CID 10606
Change-Id: I30848ab4d1e621d82281aaa7d6f84e0c2cce4084
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/qml')
-rw-r--r-- | src/qml/qml/qqmlfileselector.cpp | 8 | ||||
-rw-r--r-- | src/qml/qml/qqmlfileselector_p.h | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/qml/qml/qqmlfileselector.cpp b/src/qml/qml/qqmlfileselector.cpp index 187c3656c6..8498a4d67d 100644 --- a/src/qml/qml/qqmlfileselector.cpp +++ b/src/qml/qml/qqmlfileselector.cpp @@ -106,8 +106,8 @@ QQmlFileSelector::QQmlFileSelector(QQmlEngine* engine, QObject* parent) { Q_D(QQmlFileSelector); d->engine = engine; - interceptorInstances()->insert(d->myInstance, this); - d->engine->setUrlInterceptor(d->myInstance); + interceptorInstances()->insert(d->myInstance.data(), this); + d->engine->setUrlInterceptor(d->myInstance.data()); } QQmlFileSelector::~QQmlFileSelector() @@ -117,7 +117,7 @@ QQmlFileSelector::~QQmlFileSelector() d->engine->setUrlInterceptor(0); d->engine = 0; } - interceptorInstances()->remove(d->myInstance); + interceptorInstances()->remove(d->myInstance.data()); } QQmlFileSelectorPrivate::QQmlFileSelectorPrivate() @@ -125,7 +125,7 @@ QQmlFileSelectorPrivate::QQmlFileSelectorPrivate() Q_Q(QQmlFileSelector); ownSelector = true; selector = new QFileSelector(q); - myInstance = new QQmlFileSelectorInterceptor(this); + myInstance.reset(new QQmlFileSelectorInterceptor(this)); } /*! diff --git a/src/qml/qml/qqmlfileselector_p.h b/src/qml/qml/qqmlfileselector_p.h index 501f563ade..73a98788ee 100644 --- a/src/qml/qml/qqmlfileselector_p.h +++ b/src/qml/qml/qqmlfileselector_p.h @@ -71,7 +71,7 @@ public: QFileSelector* selector; QPointer<QQmlEngine> engine; bool ownSelector; - QQmlFileSelectorInterceptor* myInstance; + QScopedPointer<QQmlFileSelectorInterceptor> myInstance; }; class Q_QML_PRIVATE_EXPORT QQmlFileSelectorInterceptor : public QQmlAbstractUrlInterceptor |