mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +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();
|
||||
emit qmlPluginUnloaded();
|
||||
}
|
||||
|
||||
bool QmlPluginInterface::testPlugin()
|
||||
|
@ -40,6 +40,9 @@ public:
|
||||
bool testPlugin();
|
||||
void setName(const QString &name);
|
||||
|
||||
Q_SIGNALS:
|
||||
void qmlPluginUnloaded();
|
||||
|
||||
private:
|
||||
QString m_name;
|
||||
QJSValue m_jsInit;
|
||||
|
@ -19,13 +19,20 @@
|
||||
|
||||
QmlPluginLoader::QmlPluginLoader(const QString &path)
|
||||
{
|
||||
m_path = path;
|
||||
m_engine = new QQmlEngine();
|
||||
m_component = new QQmlComponent(m_engine, path);
|
||||
m_component = new QQmlComponent(m_engine, m_path);
|
||||
}
|
||||
|
||||
void QmlPluginLoader::createComponent()
|
||||
{
|
||||
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
|
||||
|
@ -22,8 +22,9 @@
|
||||
|
||||
#include "qmlplugininterface.h"
|
||||
|
||||
class QmlPluginLoader
|
||||
class QmlPluginLoader : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QmlPluginLoader(const QString &path);
|
||||
void createComponent();
|
||||
@ -31,6 +32,7 @@ public:
|
||||
QmlPluginInterface *instance() const;
|
||||
void setName(const QString &name);
|
||||
private:
|
||||
QString m_path;
|
||||
QQmlEngine *m_engine;
|
||||
QQmlComponent *m_component;
|
||||
QmlPluginInterface *m_interface;
|
||||
|
Loading…
Reference in New Issue
Block a user