I have a demo app consisting of these 3 classes. When I quit (on macos), it ends with a segfault: Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)
that I’ve traced to the Edit
destructor, specifically Selectable::notifyListenersOfDeletion
line 177: updateTimerInstance->remove (this);
, although if I remove the call to notifyListenersOfDeletion
, it occurs elsewhere in the Edit
destructor. I’m not sure what I’m doing wrong that keeps the destructor from destructing properly. I uploaded this project here in case anyone wants to run it: segfault-example.zip - Google Drive
MainComponent initializes an instance of this class:
#pragma once
#include "Clip.h"
namespace phenotype
{
class Sequencer
{
public:
Sequencer() = default;
~Sequencer() = default;
Clip clip{};
};
}
Which initializes an instance of:
#pragma once
#include "ServiceRegistry.h"
namespace phenotype
{
class Clip
{
public:
explicit Clip()
:edit(ServiceRegistry::getInstance().getClipEdit())
{
}
~Clip() = default;
te::Edit& edit;
};
}
Through this singleton:
#pragma once
#include "JuceHeader.h"
namespace phenotype
{
namespace te = tracktion_engine;
class ServiceRegistry
{
public:
ServiceRegistry() = default;
static ServiceRegistry& getInstance()
{
static ServiceRegistry instance;
return instance;
}
te::Edit& getClipEdit()
{
return clipEdit;
}
protected:
te::Engine engine{ ProjectInfo::projectName };
te::Edit clipEdit{ engine, te::createEmptyEdit(engine), te::Edit::forEditing, nullptr, 0 };
};
}