I feel like what I’m trying to do is simple enough
edit = te::loadEditFromFile(engine, fileChosen);
The Edit is loaded in just fine, but VS hits a breakpoint at the EditItemCache destructor with the following assertion
jassert (knownEditItems.empty());
Looking at knownEditItems, it holds 4 items which seem to point to the global tracks. I’m really not sure why those are still there in cache.
I’ve been trying to find a work around to no avail and I’m kinda hoping there’s a simple solution staring me in the face to which I’m blind to. I would appreciate any help.
My bad, should’ve went into a little more detail.
I made my MainComponent inherit juce::MenuBarModel methods so I can go to File->Open to get the Edit file while my application is running.
// Menu Bar Actions
void MainComponent::menuItemSelected(int menuItemID, int topLevelMenuIndex)
{
// Handle menu selections
switch (menuItemID)
{
case 1: // Open
{
// Choose an Edit file
FileChooser chooser("Select edit file", juce::File{}, "*");
if (chooser.browseForFileToOpen())
{
File fileChosen = chooser.getResult(); // Get the file
edit = te::loadEditFromFile(engine, fileChosen);
}
break;
}
case 2: // Save
{
FileChooser chooser("Select the file to save to", juce::File{}, "*");
if (chooser.browseForFileToSave(true))
{
File fileChosen = chooser.getResult(); // Get the file chosen
editFileOps.saveAs(fileChosen, true); // Save the file there
}
break; // Save the current edit
}
case 3: juce::JUCEApplication::quit(); break; // Exit
…
}
}
Another thing my MainComponent does is pass the edit to its subcomponents
All the subcomponents have an Edit reference member so they can access it. I suspected this is where my problem arises when I try to change the edit but I’m unsure exactly how or where.
You can’t take a reference to a new, empty Edit and then overwrite that when you open a new Edit. All the other objects will now be referring to a dangling reference which will cause crashes and unpredictable behaviour.
You probably want to wrap all of those objects in to something that takes an Edit and recreate them all when you load a new Edit.