From ead4cc9d62ea96cf9f60f4ef8378eeec200ac8c8 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Wed, 3 Feb 2010 10:27:44 +0000 Subject: [PATCH] use khns3 dialog; look ma, no more memory leaks as a bonus! svn path=/trunk/KDE/kdelibs/; revision=1084570 --- CMakeLists.txt | 2 +- private/packages.cpp | 36 ++++++++++-------------------------- private/packages_p.h | 10 +++------- 3 files changed, 14 insertions(+), 34 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b276bd90..c96edcd1e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -209,7 +209,7 @@ endif(PHONON_FOUND) kde4_add_library(plasma SHARED ${plasma_LIB_SRCS}) -target_link_libraries(plasma ${KDE4_KIO_LIBS} ${KDE4_KFILE_LIBS} knewstuff2 +target_link_libraries(plasma ${KDE4_KIO_LIBS} ${KDE4_KFILE_LIBS} knewstuff3 ${QT_QTUITOOLS_LIBRARY} ${QT_QTWEBKIT_LIBRARY} kdnssd threadweaver ${KDE4_SOLID_LIBS} ) diff --git a/private/packages.cpp b/private/packages.cpp index 7d1cd30af..fef363239 100644 --- a/private/packages.cpp +++ b/private/packages.cpp @@ -29,7 +29,7 @@ #include #include -#include +#include #include "plasma/private/wallpaper_p.h" @@ -37,8 +37,7 @@ namespace Plasma { PlasmoidPackage::PlasmoidPackage(QObject *parent) - : Plasma::PackageStructure(parent, QString("Plasmoid")), - m_knsEngine(0) + : Plasma::PackageStructure(parent, QString("Plasmoid")) { addDirectoryDefinition("images", "images/", i18n("Images")); QStringList mimetypes; @@ -69,11 +68,7 @@ PlasmoidPackage::PlasmoidPackage(QObject *parent) PlasmoidPackage::~PlasmoidPackage() { - delete m_knsEngine; -} - -void PlasmoidPackage::deleteNewStuffEngine() -{ + delete m_knsDialog.data(); } void PlasmoidPackage::pathChanged() @@ -89,25 +84,14 @@ void PlasmoidPackage::pathChanged() void PlasmoidPackage::createNewWidgetBrowser(QWidget *parent) { -//FIXME: memory leak below: it creates a new KNS::Engine every time it's called -// however, due to issues in the KNS2 library, reusing the same engine causes crashes :( -// if (!m_knsEngine) { - m_knsEngine = new KNS::Engine(parent); - kDebug() << "creating new kns engine" << m_knsEngine; - if (!m_knsEngine->init("plasmoids.knsrc")) { - delete m_knsEngine; - m_knsEngine = 0; - return; - } -// } + KNS3::DownloadDialog *knsDialog = m_knsDialog.data(); + if (!knsDialog) { + m_knsDialog = knsDialog = new KNS3::DownloadDialog("plasmoids.knsrc", parent); + connect(knsDialog, SIGNAL(accepted()), this, SIGNAL(newWidgetBrowserFinished())); + } - kDebug() << "successful kns engine" << m_knsEngine; - m_knsEngine->downloadDialog(this, SLOT(widgetBrowserFinished())); -} - -void PlasmoidPackage::widgetBrowserFinished() -{ - emit newWidgetBrowserFinished(); + knsDialog->show(); + knsDialog->raise(); } ThemePackage::ThemePackage(QObject *parent) diff --git a/private/packages_p.h b/private/packages_p.h index fef9938ba..f24091433 100644 --- a/private/packages_p.h +++ b/private/packages_p.h @@ -24,9 +24,9 @@ #include "plasma/wallpaper.h" #include "plasma/plasma.h" -namespace KNS +namespace KNS3 { - class Engine; + class DownloadDialog; } // namespace KNS namespace Plasma @@ -43,12 +43,8 @@ public: protected: void pathChanged(); -protected Q_SLOTS: - void widgetBrowserFinished(); - void deleteNewStuffEngine(); - private: - KNS::Engine *m_knsEngine; + QWeakPointer m_knsDialog; }; class ThemePackage : public PackageStructure