mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 01:22:10 +01:00
delete engine on qml-pluign unload
This commit is contained in:
parent
d4aa875fa6
commit
3b769f82d6
|
@ -48,6 +48,7 @@ void QmlPluginInterface::unload()
|
||||||
}
|
}
|
||||||
|
|
||||||
m_jsUnload.call();
|
m_jsUnload.call();
|
||||||
|
emit qmlPluginUnloaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QmlPluginInterface::testPlugin()
|
bool QmlPluginInterface::testPlugin()
|
||||||
|
|
|
@ -40,6 +40,9 @@ public:
|
||||||
bool testPlugin();
|
bool testPlugin();
|
||||||
void setName(const QString &name);
|
void setName(const QString &name);
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void qmlPluginUnloaded();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_name;
|
QString m_name;
|
||||||
QJSValue m_jsInit;
|
QJSValue m_jsInit;
|
||||||
|
|
|
@ -19,13 +19,20 @@
|
||||||
|
|
||||||
QmlPluginLoader::QmlPluginLoader(const QString &path)
|
QmlPluginLoader::QmlPluginLoader(const QString &path)
|
||||||
{
|
{
|
||||||
|
m_path = path;
|
||||||
m_engine = new QQmlEngine();
|
m_engine = new QQmlEngine();
|
||||||
m_component = new QQmlComponent(m_engine, path);
|
m_component = new QQmlComponent(m_engine, m_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlPluginLoader::createComponent()
|
void QmlPluginLoader::createComponent()
|
||||||
{
|
{
|
||||||
m_interface = qobject_cast<QmlPluginInterface*>(m_component->create());
|
m_interface = qobject_cast<QmlPluginInterface*>(m_component->create());
|
||||||
|
connect(m_interface, &QmlPluginInterface::qmlPluginUnloaded, this, [this]{
|
||||||
|
delete m_component;
|
||||||
|
delete m_engine;
|
||||||
|
m_engine = new QQmlEngine();
|
||||||
|
m_component = new QQmlComponent(m_engine, m_path);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
QQmlComponent *QmlPluginLoader::component() const
|
QQmlComponent *QmlPluginLoader::component() const
|
||||||
|
|
|
@ -22,8 +22,9 @@
|
||||||
|
|
||||||
#include "qmlplugininterface.h"
|
#include "qmlplugininterface.h"
|
||||||
|
|
||||||
class QmlPluginLoader
|
class QmlPluginLoader : public QObject
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit QmlPluginLoader(const QString &path);
|
explicit QmlPluginLoader(const QString &path);
|
||||||
void createComponent();
|
void createComponent();
|
||||||
|
@ -31,6 +32,7 @@ public:
|
||||||
QmlPluginInterface *instance() const;
|
QmlPluginInterface *instance() const;
|
||||||
void setName(const QString &name);
|
void setName(const QString &name);
|
||||||
private:
|
private:
|
||||||
|
QString m_path;
|
||||||
QQmlEngine *m_engine;
|
QQmlEngine *m_engine;
|
||||||
QQmlComponent *m_component;
|
QQmlComponent *m_component;
|
||||||
QmlPluginInterface *m_interface;
|
QmlPluginInterface *m_interface;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user