Best Practices for Deleting an Edit?

Currently, in preparation for creating a new edit, I am doing the following to “close” an edit…

	{
		selectionManager.deselectAll();
		editComponent = nullptr;

		edit.reset();// edit is unique_ptr

		resized();
    }

It seems to work as expected. But also seems naive. What are the best practices here to make sure everything is cleaned up properly?

I don’t think it’s strictly necessary, but we get rid of the transport before closing the edit.

        void deleteEdit()
        {
            if (transport != nullptr)
            {
                transport->freePlaybackContext();
                transport = nullptr;
            }

            previewEdit = nullptr;
        }

Getting rid of your UI first is good. You don’t want anything hanging onto a reference counted clip, track, plugin etc hanging around, since they’ll still exist but their parent edit will be gone, which could lead to trouble.

I advise to holding onto pointers from the engine as little as possible. Try and just make ValueTree objects and watch them for changes if possible.

I don’t think you need to do this anymore, it’s done in the Edit destructor.