Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor deleteUnusedChannels in FxMixerView #5564

Merged
merged 5 commits into from
Jul 9, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 17 additions & 27 deletions src/gui/FxMixerView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,38 +439,28 @@ void FxMixerView::deleteUnusedChannels()
tracks += Engine::getSong()->tracks();
tracks += Engine::getBBTrackContainer()->tracks();

// go through all FX Channels
for(int i = m_fxChannelViews.size()-1; i > 0; --i)
bool inUse[m_fxChannelViews.size()] = {false};
DomClark marked this conversation as resolved.
Show resolved Hide resolved

for (Track* t: tracks)
Spekular marked this conversation as resolved.
Show resolved Hide resolved
{
// check if an instrument references to the current channel
bool empty=true;
for( Track* t : tracks )
int channel = 0;
Spekular marked this conversation as resolved.
Show resolved Hide resolved
if (t->type() == Track::InstrumentTrack)
{
if( t->type() == Track::InstrumentTrack )
{
InstrumentTrack* inst = dynamic_cast<InstrumentTrack *>( t );
if( i == inst->effectChannelModel()->value(0) )
{
empty=false;
break;
}
}
else if( t->type() == Track::SampleTrack )
{
SampleTrack *strack = dynamic_cast<SampleTrack *>( t );
if( i == strack->effectChannelModel()->value(0) )
{
empty=false;
break;
}
}
InstrumentTrack* inst = dynamic_cast<InstrumentTrack *>(t);
channel = inst->effectChannelModel()->value();
}
FxChannel * ch = Engine::fxMixer()->effectChannel( i );
// delete channel if no references found
if( empty && ch->m_receives.isEmpty() )
else if (t->type() == Track::SampleTrack)
{
deleteChannel( i );
SampleTrack *strack = dynamic_cast<SampleTrack *>(t);
channel = strack->effectChannelModel()->value();
}
inUse[channel] = true;
Spekular marked this conversation as resolved.
Show resolved Hide resolved
}

for(int i = m_fxChannelViews.size()-1; i > 0; --i)
Spekular marked this conversation as resolved.
Show resolved Hide resolved
Spekular marked this conversation as resolved.
Show resolved Hide resolved
{
if(!inUse[i] && Engine::fxMixer()->effectChannel(i)->m_receives.isEmpty())
Spekular marked this conversation as resolved.
Show resolved Hide resolved
{ deleteChannel(i); }
}
}

Expand Down