Skip to content

Commit c44ab66

Browse files
authored
Merge pull request #31831 from kryksyh/refactor_context_inject
Added missing context injects
2 parents d5acce1 + c4b5a90 commit c44ab66

File tree

30 files changed

+48
-45
lines changed

30 files changed

+48
-45
lines changed

src/appshell/qml/MuseScore/AppShell/welcomedialogmodel.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
using namespace mu::appshell;
2727

2828
WelcomeDialogModel::WelcomeDialogModel()
29+
: muse::Injectable(muse::iocCtxForQmlObject(this))
2930
{
3031
}
3132

src/braille/qml/MuseScore/Braille/braillemodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ using namespace mu::braille;
2626
using namespace mu::notation;
2727

2828
BrailleModel::BrailleModel(QObject* parent)
29-
: QObject(parent)
29+
: QObject(parent), muse::Injectable(muse::iocCtxForQmlObject(this))
3030
{
3131
}
3232

src/engraving/api/v1/qmlpluginapi.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ void PluginAPI::setup(QQmlEngine* e)
234234
}
235235

236236
PluginAPI::PluginAPI(QQuickItem* parent)
237-
: QQuickItem(parent)
237+
: QQuickItem(parent), muse::Injectable(muse::iocCtxForQmlObject(this))
238238
{
239239
setRequiresScore(true); // by default plugins require a score to work
240240
}

src/framework/audio/common/iaudiothreadsecurer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "global/modularity/imoduleinterface.h"
3030

3131
namespace muse::audio {
32-
class IAudioThreadSecurer : MODULE_EXPORT_INTERFACE
32+
class IAudioThreadSecurer : MODULE_GLOBAL_EXPORT_INTERFACE
3333
{
3434
INTERFACE_ID(IAudioThreadSecurer)
3535
public:

src/framework/global/modularity/ioccontext.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ muse::Injectable::GetContext muse::iocCtxForQmlObject(const QObject* o)
3838
engine = qmlEngine(p);
3939
}
4040

41-
IF_ASSERT_FAILED(engine) {
41+
if (!engine) {
42+
LOGW() << "Engine is not set for QML Object: " << o->metaObject()->className();
4243
return modularity::ContextPtr();
4344
}
4445

src/framework/global/thirdparty/kors_modularity/modularity/injectable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Injectable
1313

1414
using GetContext = std::function<modularity::ContextPtr ()>;
1515

16-
Injectable(const modularity::ContextPtr& ctx = nullptr)
16+
Injectable(const modularity::ContextPtr& ctx)
1717
: m_ctx(ctx) {}
1818

1919
Injectable(const Injectable* inj)

src/framework/network/internal/networkmanager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class QNetworkRequest;
3535
class QNetworkReply;
3636

3737
namespace muse::network {
38-
class NetworkManager : public QObject, public INetworkManager, public Injectable, public async::Asyncable
38+
class NetworkManager : public QObject, public INetworkManager, public async::Asyncable
3939
{
4040
Q_OBJECT
4141

src/framework/ui/qml/Muse/Ui/windowsmodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
using namespace muse::ui;
2828

2929
WindowsModel::WindowsModel(QObject* parent)
30-
: QObject(parent)
30+
: QObject(parent), muse::Injectable(muse::iocCtxForQmlObject(this))
3131
{
3232
}
3333

src/framework/uicomponents/qml/Muse/UiComponents/toolbaritem.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ using namespace muse::uicomponents;
3030
using namespace muse::ui;
3131

3232
ToolBarItem::ToolBarItem(QObject* parent)
33-
: QObject(parent)
33+
: QObject(parent), Injectable(iocCtxForQmlObject(this))
3434
{
3535
}
3636

3737
ToolBarItem::ToolBarItem(const UiAction& action, ToolBarItemType::Type type, QObject* parent)
38-
: QObject(parent)
38+
: QObject(parent), Injectable(iocCtxForQmlObject(this))
3939
{
4040
m_id = QString::fromStdString(action.code);
4141
m_action = action;

src/framework/vst/internal/fx/vstfxresolver.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@
3030
#include "../../ivstmodulesrepository.h"
3131

3232
namespace muse::vst {
33-
class VstFxResolver : public audio::fx::AbstractFxResolver
33+
class VstFxResolver : public audio::fx::AbstractFxResolver, public muse::Injectable
3434
{
35-
muse::Inject<IVstModulesRepository> pluginModulesRepo;
36-
muse::Inject<IVstInstancesRegister> instancesRegister;
35+
muse::Inject<IVstModulesRepository> pluginModulesRepo { this };
36+
muse::Inject<IVstInstancesRegister> instancesRegister { this };
3737
public:
38+
VstFxResolver(const muse::modularity::ContextPtr& ctx)
39+
: muse::Injectable(ctx) {}
3840
// IFxResolver::IResolver interface
3941
audio::AudioResourceMetaList resolveResources() const override;
4042
void refresh() override;

0 commit comments

Comments
 (0)