Component that needs access to edit and engine

Heyhey!
I still have problems I expect to be first steps problems.
I have a main component that has a childcomponent that needs access to the engine and edit.
Till now i instantiate child component like this:

that I would like to Instantiate like
ParentComponent(){
public
ParentComponent(){
childcomponent = std::make_unique(engine, *edit, selectionManager, *editComponent);
}
private
std::unique_ptr childComponent;
}

And the ChildComponent:
class ChildComponent : public juce::Component {
public:
ChildComponent (tracktion_engine::Engine& en, tracktion_engine::Edit& ed,
tracktion_engine::SelectionManager& sm, EditComponent& ec )
: engine(en), edit(ed), selectionManager(sm), editComponent(ec) {
public:

private:
tracktion_engine::Engine& engine;
tracktion_engine::SelectionManager& selectionManager;
tracktion_engine::Edit& edit;
EditComponent& editComponent;
}

I guess it is very bad practice. And I get a badExcess problem now. But I dont know how to do it better. Any advice?

what tutorials / videos articles would you recommend to learn about these things?

Passing the engine and edits to children by reference is generally ok.
I’m not sure what kind of problems you’re getting though. It’s probably something else related to your lifetimes.

Its a bit too general to recommend specific tutorials. Have you worked your way through the JUCE tutorials?

hey dave, thanks for you help.
yes, I did most of the tutorials.
It was somehow overwhelming to start tracktion juce c++ at the same time and I guess I hacked myself through too fast and have now complexities I dont understand missing basic principals.
Thank you very much :slight_smile:

I will try to get to the concrete problem and then maybe ask here again. Thanks

got it. Had nothing to do with the parent/child relationship at all.

i guess what I am missing / not finding in the juce tutorials is a basic how to manage and organize your code tutorial.
I have multiple components with a shared set of utility functions and the way I do connections so far dont follow any concept that I read or learned or saw. The tutorials i saw dont deal with that and maybe it is hard to generalize or a c++ knowledge Thing that has nothing to do with juce. not sure about it. What I know: My code is some flaky mess and I dont know how to clean up :smiley: