Skip to content

Commit

Permalink
Merge pull request #2675 from Fastigium/deletechannelfix
Browse files Browse the repository at this point in the history
Fix crashes on deleting an FX channel. Fixes #2667
  • Loading branch information
Fastigium committed Mar 26, 2016
2 parents 770c07f + 82055a9 commit d1739ce
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
1 change: 0 additions & 1 deletion include/FxMixer.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class FxChannel : public ThreadableJob
BoolModel m_soloModel;
FloatModel m_volumeModel;
QString m_name;
QMutex m_lock;
int m_channelIndex; // what channel index are we
bool m_queued; // are we queued up for rendering yet?
bool m_muted; // are we muted? updated per period so we don't have to call m_muteModel.value() twice
Expand Down
1 change: 1 addition & 0 deletions include/InstrumentTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ protected slots:
void updateBaseNote();
void updatePitch();
void updatePitchRange();
void updateEffectChannel();


private:
Expand Down
13 changes: 5 additions & 8 deletions src/core/FxMixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ FxChannel::FxChannel( int idx, Model * _parent ) :
m_soloModel( false, _parent ),
m_volumeModel( 1.0, 0.0, 2.0, 0.001, _parent ),
m_name(),
m_lock(),
m_channelIndex( idx ),
m_queued( false ),
m_dependenciesMet( 0 )
Expand Down Expand Up @@ -284,7 +283,8 @@ void FxMixer::toggledSolo()

void FxMixer::deleteChannel( int index )
{
m_fxChannels[index]->m_lock.lock();
// lock the mixer so channel deletion is performed between mixer rounds
Engine::mixer()->lock();

FxChannel * ch = m_fxChannels[index];

Expand Down Expand Up @@ -344,6 +344,8 @@ void FxMixer::deleteChannel( int index )
r->updateName();
}
}

Engine::mixer()->unlock();
}


Expand Down Expand Up @@ -543,15 +545,10 @@ FloatModel * FxMixer::channelSendModel( fx_ch_t fromChannel, fx_ch_t toChannel )

void FxMixer::mixToChannel( const sampleFrame * _buf, fx_ch_t _ch )
{
// The first check is for the case where the last fxchannel was deleted but
// there was a race condition where it had to be processed.
if( _ch < m_fxChannels.size() &&
m_fxChannels[_ch]->m_muteModel.value() == false )
if( m_fxChannels[_ch]->m_muteModel.value() == false )
{
m_fxChannels[_ch]->m_lock.lock();
MixHelpers::add( m_fxChannels[_ch]->m_buffer, _buf, Engine::mixer()->framesPerPeriod() );
m_fxChannels[_ch]->m_hasInput = true;
m_fxChannels[_ch]->m_lock.unlock();
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/gui/FxMixerView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,9 @@ void FxMixerView::deleteChannel(int index)
delete m_fxChannelViews[index]->m_fader;
delete m_fxChannelViews[index]->m_muteBtn;
delete m_fxChannelViews[index]->m_soloBtn;
delete m_fxChannelViews[index]->m_fxLine;
// delete fxLine later to prevent a crash when deleting from context menu
m_fxChannelViews[index]->m_fxLine->hide();
m_fxChannelViews[index]->m_fxLine->deleteLater();
delete m_fxChannelViews[index]->m_rackView;
delete m_fxChannelViews[index];
m_channelAreaWidget->adjustSize();
Expand Down
11 changes: 9 additions & 2 deletions src/tracks/InstrumentTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ InstrumentTrack::InstrumentTrack( TrackContainer* tc ) :
connect( &m_baseNoteModel, SIGNAL( dataChanged() ), this, SLOT( updateBaseNote() ) );
connect( &m_pitchModel, SIGNAL( dataChanged() ), this, SLOT( updatePitch() ) );
connect( &m_pitchRangeModel, SIGNAL( dataChanged() ), this, SLOT( updatePitchRange() ) );
connect( &m_effectChannelModel, SIGNAL( dataChanged() ), this, SLOT( updateEffectChannel() ) );
}


Expand Down Expand Up @@ -220,8 +221,6 @@ void InstrumentTrack::processAudioBuffer( sampleFrame* buf, const fpp_t frames,
}
}
}

m_audioPort.setNextFxChannel( m_effectChannelModel.value() );
}


Expand Down Expand Up @@ -558,6 +557,14 @@ void InstrumentTrack::updatePitchRange()



void InstrumentTrack::updateEffectChannel()
{
m_audioPort.setNextFxChannel( m_effectChannelModel.value() );
}




int InstrumentTrack::masterKey( int _midi_key ) const
{

Expand Down

0 comments on commit d1739ce

Please sign in to comment.