Skip to content

Commit

Permalink
Fix ChannelShared objects not being deleted on Channel deletion (#695)
Browse files Browse the repository at this point in the history
  • Loading branch information
gvnnz committed Nov 20, 2024
1 parent 6901ad0 commit 5fdd3ca
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/core/channels/channelManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ void ChannelManager::removeTrack(std::size_t trackIndex)
{
assert(canRemoveTrack(trackIndex));

const Channel& ch = m_model.get().tracks.get(trackIndex).getGroupChannel();

m_model.removeChannelShared(*ch.shared);
m_model.get().tracks.remove(trackIndex);
m_model.swap(model::SwapType::HARD);
}
Expand Down Expand Up @@ -278,6 +281,7 @@ void ChannelManager::deleteChannel(ID channelId)
const Channel& ch = m_model.get().tracks.getChannel(channelId);
const Wave* wave = ch.sampleChannel ? ch.sampleChannel->getWave() : nullptr;

m_model.removeChannelShared(*ch.shared);
m_model.get().tracks.getByChannel(channelId).removeChannel(channelId);
m_model.swap(model::SwapType::HARD);

Expand Down
6 changes: 6 additions & 0 deletions src/core/model/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,12 @@ void Model::removeWave(const Wave& w)
m_shared.removeWave(w);
}

void Model::removeChannelShared(const ChannelShared& c)
{
const SharedLock lock = lockShared(SwapType::NONE);
m_shared.removeChannel(c);
}

/* -------------------------------------------------------------------------- */

void Model::clearPlugins()
Expand Down
1 change: 1 addition & 0 deletions src/core/model/model.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ class Model

void removePlugin(const Plugin&);
void removeWave(const Wave&);
void removeChannelShared(const ChannelShared&);

void clearPlugins();
void clearWaves();
Expand Down
1 change: 1 addition & 0 deletions src/core/model/shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ ChannelShared& Shared::addChannel(std::unique_ptr<ChannelShared> cs) { return ad

void Shared::removePlugin(const Plugin& p) { remove_(m_plugins, p); }
void Shared::removeWave(const Wave& w) { remove_(m_waves, w); }
void Shared::removeChannel(const ChannelShared& c) { remove_(m_channels, c); }

/* -------------------------------------------------------------------------- */

Expand Down
1 change: 1 addition & 0 deletions src/core/model/shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class Shared

void removePlugin(const Plugin&);
void removeWave(const Wave&);
void removeChannel(const ChannelShared&);

void clearPlugins();
void clearWaves();
Expand Down

0 comments on commit 5fdd3ca

Please sign in to comment.