prep this for fixing the memory leak; at least it doesn't crash anymore, along with my changes to KNS that are upcoming

svn path=/trunk/KDE/kdelibs/; revision=990700
This commit is contained in:
Aaron J. Seigo 2009-07-03 02:17:25 +00:00
parent e1f9f6739a
commit baee782e6f
2 changed files with 31 additions and 5 deletions

View File

@ -37,7 +37,8 @@ namespace Plasma
{
PlasmoidPackage::PlasmoidPackage(QObject *parent)
: Plasma::PackageStructure(parent, QString("Plasmoid"))
: Plasma::PackageStructure(parent, QString("Plasmoid")),
m_knsEngine(0)
{
addDirectoryDefinition("images", "images/", i18n("Images"));
QStringList mimetypes;
@ -66,6 +67,11 @@ PlasmoidPackage::PlasmoidPackage(QObject *parent)
setRequired("mainscript", true);
}
PlasmoidPackage::~PlasmoidPackage()
{
delete m_knsEngine;
}
void PlasmoidPackage::pathChanged()
{
KDesktopFile config(path() + "/metadata.desktop");
@ -79,10 +85,20 @@ void PlasmoidPackage::pathChanged()
void PlasmoidPackage::createNewWidgetBrowser(QWidget *parent)
{
KNS::Engine *engine = new KNS::Engine(parent);
if (engine->init("plasmoids.knsrc")) {
engine->downloadDialog(this, SLOT(widgetBrowserFinished()));
//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;
}
// }
kDebug() << "successful kns engine" << m_knsEngine;
m_knsEngine->downloadDialog(this, SLOT(widgetBrowserFinished()));
}
void PlasmoidPackage::widgetBrowserFinished()

View File

@ -24,6 +24,11 @@
#include "plasma/wallpaper.h"
#include "plasma/plasma.h"
namespace KNS
{
class Engine;
} // namespace KNS
namespace Plasma
{
@ -34,6 +39,7 @@ class PlasmoidPackage : public PackageStructure
Q_OBJECT
public:
explicit PlasmoidPackage(QObject *parent = 0);
~PlasmoidPackage();
void createNewWidgetBrowser(QWidget *parent = 0);
protected:
@ -41,6 +47,10 @@ protected:
protected Q_SLOTS:
void widgetBrowserFinished();
void deleteNewStuffEngine();
private:
KNS::Engine *m_knsEngine;
};
class ThemePackage : public PackageStructure