Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions framework/extensions/iextensionsuiengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,9 @@ class IExtensionsUiEngine : MODULE_CONTEXT_INTERFACE

virtual QQmlEngine* qmlEngine() const = 0;
virtual QQmlEngine* qmlEngineApiV1() const = 0;

//! NOTE Drops what the engines have cached of the plugins on disk, so that
//! the next run of a plugin reads it again
virtual void clearComponentCache() = 0;
};
}
5 changes: 5 additions & 0 deletions framework/extensions/internal/extensionsprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ static Uri VIEWER_URI = Uri("muse://extensions/viewer");

void ExtensionsProvider::reloadExtensions()
{
//! NOTE Without this, reloading picks up a plugin's manifest but keeps
//! running the code the engine compiled the first time, so edits to a
//! plugin only take effect after a restart.
extensionsUiEngine()->clearComponentCache();

extensionsRegister()->reload();
}

Expand Down
2 changes: 2 additions & 0 deletions framework/extensions/internal/extensionsprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "../iextensionsconfiguration.h"
#include "../iextensionsregister.h"
#include "../iextensionsprovider.h"
#include "../iextensionsuiengine.h"
#include "interactive/iinteractive.h"
#include "io/ifilesystem.h"

Expand All @@ -37,6 +38,7 @@ class ExtensionsProvider : public IExtensionsProvider, public Contextable, publi
GlobalInject<IExtensionsConfiguration> configuration;
GlobalInject<IExtensionsRegister> extensionsRegister;
GlobalInject<io::IFileSystem> fileSystem;
ContextInject<IExtensionsUiEngine> extensionsUiEngine = { this };
ContextInject<IInteractive> interactive = { this };

public:
Expand Down
15 changes: 15 additions & 0 deletions framework/extensions/internal/extensionsuiengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,18 @@ QQmlEngine* ExtensionsUiEngine::qmlEngineApiV1() const
{
return const_cast<ExtensionsUiEngine*>(this)->engineV1();
}

void ExtensionsUiEngine::clearComponentCache()
{
//! NOTE The engines cache every QML component they have compiled, so a plugin
//! edited on disk keeps running its old code until the cache is dropped.
//! The engines themselves stay: a plugin window left open was built by one of
//! them, and outlives the reload.
if (m_engine) {
m_engine->clearComponentCache();
}

if (m_engineV1) {
m_engineV1->clearComponentCache();
}
}
5 changes: 3 additions & 2 deletions framework/extensions/internal/extensionsuiengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ class ExtensionsUiEngine : public QObject, public IExtensionsUiEngine, public Co

~ExtensionsUiEngine();

QQmlEngine* qmlEngine() const;
QQmlEngine* qmlEngineApiV1() const;
QQmlEngine* qmlEngine() const override;
QQmlEngine* qmlEngineApiV1() const override;
void clearComponentCache() override;

private:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ void ExtensionsListModel::editShortcut(const QString& extensionUri)

void ExtensionsListModel::reloadPlugins()
{
extensionsRegister()->reload();
//! NOTE Through the provider: reloading the register alone leaves the QML
//! engines holding the code they compiled the first time
provider()->reloadExtensions();
}

void ExtensionsListModel::removeExtension(const QString& uri)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "interactive/iinteractive.h"
#include "extensions/iextensioninstaller.h"
#include "extensions/iextensionsconfiguration.h"
#include "extensions/iextensionsprovider.h"
#include "extensions/iextensionsregister.h"
#include "shortcuts/ishortcutsregister.h"

Expand All @@ -46,6 +47,7 @@ class ExtensionsListModel : public QAbstractListModel, public QQmlParserStatus,

GlobalInject<IExtensionsConfiguration> configuration;
GlobalInject<IExtensionsRegister> extensionsRegister;
ContextInject<IExtensionsProvider> provider = { this };
ContextInject<IExtensionInstaller> installer = { this };
ContextInject<IInteractive> interactive = { this };
ContextInject<shortcuts::IShortcutsRegister> shortcutsRegister = { this };
Expand Down