diff options
author | mread <qt-info@nokia.com> | 2009-08-06 09:36:31 (GMT) |
---|---|---|
committer | mread <qt-info@nokia.com> | 2009-08-06 09:36:31 (GMT) |
commit | 252e1e7c98eca34add9f4531edf800fc1b47fde6 (patch) | |
tree | 2de640f903275ba9063bdea34cdd8f2cda9769d1 | |
parent | 08587c9b18f94b3e108ee54489801a11d61ee29d (diff) | |
download | Qt-252e1e7c98eca34add9f4531edf800fc1b47fde6.zip Qt-252e1e7c98eca34add9f4531edf800fc1b47fde6.tar.gz Qt-252e1e7c98eca34add9f4531edf800fc1b47fde6.tar.bz2 |
plugin factory loader memory leak protection
-rw-r--r-- | src/corelib/plugin/qfactoryloader.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp index 3b44b47..2e852f7 100644 --- a/src/corelib/plugin/qfactoryloader.cpp +++ b/src/corelib/plugin/qfactoryloader.cpp @@ -64,6 +64,7 @@ class QFactoryLoaderPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QFactoryLoader) public: QFactoryLoaderPrivate(){} + ~QFactoryLoaderPrivate(); mutable QMutex mutex; QByteArray iid; QList<QLibraryPrivate*> libraryList; @@ -76,6 +77,12 @@ public: void unloadPath(const QString &path); }; +QFactoryLoaderPrivate::~QFactoryLoaderPrivate() +{ + for (int i = 0; i < libraryList.count(); ++i) + libraryList.at(i)->release(); +} + QFactoryLoader::QFactoryLoader(const char *iid, const QString &suffix, Qt::CaseSensitivity cs) @@ -89,8 +96,8 @@ QFactoryLoader::QFactoryLoader(const char *iid, QMutexLocker locker(qt_factoryloader_mutex()); - qt_factory_loaders()->append(this); update(); + qt_factory_loaders()->append(this); } @@ -197,10 +204,6 @@ void QFactoryLoader::update() QFactoryLoader::~QFactoryLoader() { - Q_D(QFactoryLoader); - for (int i = 0; i < d->libraryList.count(); ++i) - d->libraryList.at(i)->release(); - QMutexLocker locker(qt_factoryloader_mutex()); qt_factory_loaders()->removeAll(this); } |