Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ioc context to inject. Step 5 #22808

Merged
merged 2 commits into from
May 23, 2024

Conversation

igorkorsukov
Copy link
Contributor

No description provided.

@igorkorsukov igorkorsukov marked this pull request as ready for review May 21, 2024 13:43
@cbjeukendrup
Copy link
Contributor

Perhaps for "stateless" things, like ProjectCreator, and Renderer, we could perhaps use one global instance, instead of one for each context. But we can do that in the future; I understand that it might be better to apply a uniform approach right now, and look later which specific cases can be refined.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the situation with these changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what to do with them (
They fail for me both locally and in СI.
I took the master, and these tests also fail, both with and without install.
Previously, they always failed for me locally, but they worked on СI..

Maybe you have some ideas and knowledge about these tests?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would need to investigate that. I don't recall having them seen failing yet , but I haven't run them locally for a while. Is there perhaps a log of a CI run where I can see how they fail?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about merge now as is (with commented tests), but later I fix it separated?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do that, I don't really have ideas right now of what could be it. Perhaps make tech debt issue for it, so that we don't forget.

@@ -101,7 +101,7 @@ Ret DrawDataGenerator::processFile(const muse::io::path_t& scoreFile, const muse

DrawDataPtr DrawDataGenerator::genDrawData(const muse::io::path_t& scorePath, const GenOpt& opt) const
{
MasterScore* score = compat::ScoreAccess::createMasterScoreWithBaseStyle();
MasterScore* score = compat::ScoreAccess::createMasterScoreWithBaseStyle(nullptr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the consequence of passing nullptr here? Is it that this score will not be able to find EngravingConfiguration and Renderer? (I guess that's fine (until the moment that it isn't fine anymore because it causes crashes), but just wanted to check)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now it is done so that if a ioc context is null, then the global ioc is used. It might be worth doing this more explicitly, for example passing "global ioc context"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But not all interfaces are registered to the global ioc context, right? So those that aren't registered there, those will not be found here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All interfaces are registered in the global ioc, because the “global ioc” will simply be the first ioc (of the first window). Now this is not entirely true, but it will be so :)

@@ -175,6 +175,16 @@ EngravingItemList EngravingItem::childrenItems(bool all) const
return list;
}

const std::shared_ptr<IEngravingConfiguration>& EngravingItem::configuration() const
{
return score()->configuration.get();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it right that the purpose here is to prevent making EngravingItem/EngravingObject Injectable, and only Score? (makes sense, just checking if I understand correctly)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right!! Otherwise, we will have to pass a ioc context to each object... Although we are already passing the parent, and ultimately has access to a score.

@igorkorsukov
Copy link
Contributor Author

Perhaps for "stateless" things, like ProjectCreator, and Renderer, we could perhaps use one global instance, instead of one for each context. But we can do that in the future; I understand that it might be better to apply a uniform approach right now, and look later which specific cases can be refined.

Yes, I thought about this too and came to the same conclusions.
In the future, we may make a special base interface, a marker, that needs to be inherited from in order to become a "global" instance. And a number of other things will need to be done for everything to work reliably and automatically.

@igorkorsukov igorkorsukov merged commit e2fab5f into musescore:master May 23, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants