Merge pull request #192 from wongcc966422/ghostPeakController
Fixed duplicate controllers issue
This commit is contained in:
@@ -54,7 +54,6 @@ public:
|
||||
virtual QString nodeName() const;
|
||||
|
||||
static PeakControllerEffectVector s_effects;
|
||||
static int s_lastEffectId;
|
||||
|
||||
|
||||
public slots:
|
||||
|
||||
@@ -278,6 +278,8 @@ public slots:
|
||||
|
||||
void addBBTrack();
|
||||
|
||||
bool isLoadingProject();
|
||||
|
||||
|
||||
private slots:
|
||||
void insertBar();
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
|
||||
#include "embed.cpp"
|
||||
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
@@ -61,6 +60,7 @@ PeakControllerEffect::PeakControllerEffect(
|
||||
Model * _parent,
|
||||
const Descriptor::SubPluginFeatures::Key * _key ) :
|
||||
Effect( &peakcontrollereffect_plugin_descriptor, _parent, _key ),
|
||||
m_effectId( rand() ),
|
||||
m_peakControls( this ),
|
||||
m_lastSample( 0 ),
|
||||
m_lastRMS( -1 ),
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "peak_controller_effect_controls.h"
|
||||
#include "peak_controller_effect.h"
|
||||
#include "preset_preview_play_handle.h"
|
||||
#include "song.h"
|
||||
|
||||
|
||||
PeakControllerEffectControls::
|
||||
@@ -60,14 +61,23 @@ void PeakControllerEffectControls::loadSettings( const QDomElement & _this )
|
||||
m_absModel.loadSettings( _this, "abs" );
|
||||
m_amountMultModel.loadSettings( _this, "amountmult" );
|
||||
|
||||
int effectId = _this.attribute( "effectId" ).toInt();
|
||||
if( effectId > PeakController::s_lastEffectId )
|
||||
/*If the peak controller effect is NOT loaded from project,
|
||||
* m_effectId stored is useless.
|
||||
* Reason to assign a random number to it:
|
||||
* If the user clone the instrument, and m_effectId is cloned, and
|
||||
* m_effectId is copied, then there would be two instruments
|
||||
* having the same id.
|
||||
*/
|
||||
if( engine::getSong()->isLoadingProject() == true )
|
||||
{
|
||||
PeakController::s_lastEffectId = effectId;
|
||||
m_effect->m_effectId = _this.attribute( "effectId" ).toInt();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_effect->m_effectId = rand();
|
||||
}
|
||||
m_effect->m_effectId = effectId;
|
||||
|
||||
if( m_effect->m_autoController && presetPreviewPlayHandle::isPreviewing() == false )
|
||||
if( m_effect->m_autoController && ( engine::getSong()->isLoadingProject() == true || presetPreviewPlayHandle::isPreviewing() == false ) )
|
||||
{
|
||||
delete m_effect->m_autoController;
|
||||
m_effect->m_autoController = 0;
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
#include "ControllerDialog.h"
|
||||
#include "plugins/peak_controller_effect/peak_controller_effect.h"
|
||||
|
||||
int PeakController::s_lastEffectId = 0;
|
||||
PeakControllerEffectVector PeakController::s_effects;
|
||||
|
||||
|
||||
|
||||
@@ -258,12 +258,7 @@ ConstNotePlayHandleList presetPreviewPlayHandle::nphsOfInstrumentTrack(
|
||||
|
||||
bool presetPreviewPlayHandle::isPreviewing()
|
||||
{
|
||||
bool ret = s_previewTC->m_dataMutex.tryLock();
|
||||
if( ret == true )
|
||||
{
|
||||
s_previewTC->m_dataMutex.unlock();
|
||||
}
|
||||
return ret;
|
||||
return s_previewTC->isPreviewing();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1494,6 +1494,13 @@ void song::removeController( Controller * _controller )
|
||||
|
||||
|
||||
|
||||
|
||||
bool song::isLoadingProject()
|
||||
{
|
||||
return m_loadingProject;
|
||||
}
|
||||
|
||||
|
||||
#include "moc_song.cxx"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user