Can't select multiple Clips (SelectionManager)

Or you can remove these lines:

using namespace tracktion_engine;
DECLARE_SELECTABLE_OBJECT_AND_CLASS (tracktion_engine::Clip, SelectableClipClass)

and replace them with this:

static tracktion_engine::SelectableClass::ClassInstance<SelectableClipClass, tracktion_engine::Clip> selectableClipClass;

fatal error LNK1169: one or more multiply defined symbols found

Okay, replacing macro and then making test function static worked. But it throws this exception:

I moved SelectableClipClass to Utilities.h and doing this on clicking on ClipComponent:


It doesn’t throw multiple SelectableClasses exception, but it triggers this jassert !nullptr

Forgot to actually select tracktion_engine::Clip. When I select it before this check, it’s still triggering multiple SelectableClasses think they apply to this object.

Same thing happens when I make my ClipComponent Selectable and make SelectableClipComponentClass for it.

I don’t think you’re running the exact code that I suggested.
The assertion you mention here:

is stating that you’ve registered the same SelectableClass twice. I’m guessing that’s because you’ve included the RecordingDemo.h or at least the code I wrote twice.
This must only be in a single translation unit.
__
Honestly, if you’ve done it as I suggest it will work.
You shouldn’t be making your ClipComponent selectable, the selectable is the underlying tracktion_engine Clip object. Your ClipComponent can then respond to being selected by listening for changes to the SelectionManager and calling isSelected.

RecordingDemo is included in Main.cpp. Just moved SelectableClass definition to Main.cpp and it doesn’t throw and selection works properly. I’m assuming it shouldn’t be in Main.cpp, but in this case where should I put it? And where should I put your testSelectableClass() function? It needs to know definition of SelectableClipClass?

There isn’t anything Tracktion Engine special about this, it’s standard C++ linkage stuff.

Your SelectableClipClass declaration can be anywhere.

The selectableClipClass instance (the line below) can only appear in a single translation unit so needs to be in only a single cpp file.
static tracktion_engine::SelectableClass::ClassInstance<SelectableClipClass, tracktion_engine::Clip> selectableClipClass;


It works where I originally said to put it as the original RecordingDemo.h code is only compiled once, via Main.cpp.
If you’ve changed the project structure, added new files, included things multiple times etc. you’ll need to figure out where it should go based on your project structure.

1 Like

Sorry, I’m new to C++, it’s my second month programming. Not just C++, any sort of coding. And I’ve been “looking at” C++ here and there for the past 7 months or so.

Thank you for your help, it makes a huge difference.

Wow, well you’re making good progress if you’ve only been coding for a month :+1:
It’s just that these kinds of things will keep coming up so it might be a good time to learn some of the C++ fundamentals.

1 Like

Thank you. I’m constantly looking up info and learning better ways of C++ and coding in general. And what’s the better way to learn than to dive headfirst into something seemingly out of my reach. From simple sample midi pad sampler straight to my own DAW to address inconveniences that Cubase has for my workflow :sweat_smile:

In regards to SelectableClasses. I’ll just create a header file to store all SelectableClasses that I’m going to need and include it in Main.cpp. (I had to change structure of RecordingDemo because, as I mentioned in one of my posts, I couldn’t generate PIP for demos automatically and thus I assembled new structure for the project and just included files from the demo).