Hi,
I’m trying to deal with a multi-edit management but when i close the app this assert is reached :
/** The first call to this method will create an internal object that is shared by all weak
references to the object.
*/
SharedRef getSharedPointer (ObjectType* object)
{
if (sharedPointer == nullptr)
{
sharedPointer = *new SharedPointer (object);
}
else
{
// You're trying to create a weak reference to an object that has already been deleted!!
jassert (sharedPointer->get() != nullptr);
}
return sharedPointer;
}
In my case i have a reference to the active Project ( currentPrj ) and to create a new edit i call this method :
std::unique_ptr<Edit> getEditForFile(const File& editFile,ProjectItemID id) {
auto editState = te::loadEditFromFile(egine, editFile, id);
if (editState.isValid()) {
Edit::Options options =
{
engine,
editState,
id,
Edit::EditRole::forEditing,
nullptr,
Edit::getDefaultNumUndoLevels(),
[editFile] { return editFile; },
{}
};
return std::make_unique<Edit>(options);
}
jassertfalse;
return {};
}
the getEditForFile() method is called from this one :
Edit* createEdit(File&file,ProjectItemID id){
return edits.add(std::move(getEditForFile(file,id)));
}
Where “edits” is an OwnedArray to keep them alive in the ActiveEdit
Some hints to deal with the multi-edit management ?