From 8d4b467ddc278242123b8f948e77aa76ef4cecb9 Mon Sep 17 00:00:00 2001 From: Wong Cho Ching Date: Wed, 29 Jan 2014 18:44:52 +0800 Subject: [PATCH 1/4] Fixed duplicate controllers issue --- include/song.h | 2 ++ .../peak_controller_effect_controls.cpp | 3 ++- src/core/preset_preview_play_handle.cpp | 7 +------ src/core/song.cpp | 7 +++++++ 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/include/song.h b/include/song.h index ed6c18872..58536ba25 100644 --- a/include/song.h +++ b/include/song.h @@ -278,6 +278,8 @@ public slots: void addBBTrack(); + bool isLoadingProject(); + private slots: void insertBar(); diff --git a/plugins/peak_controller_effect/peak_controller_effect_controls.cpp b/plugins/peak_controller_effect/peak_controller_effect_controls.cpp index 34ee79a11..740b2c416 100644 --- a/plugins/peak_controller_effect/peak_controller_effect_controls.cpp +++ b/plugins/peak_controller_effect/peak_controller_effect_controls.cpp @@ -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:: @@ -67,7 +68,7 @@ void PeakControllerEffectControls::loadSettings( const QDomElement & _this ) } 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; diff --git a/src/core/preset_preview_play_handle.cpp b/src/core/preset_preview_play_handle.cpp index 22ff31a50..ca247c44a 100644 --- a/src/core/preset_preview_play_handle.cpp +++ b/src/core/preset_preview_play_handle.cpp @@ -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(); } diff --git a/src/core/song.cpp b/src/core/song.cpp index a2c5457aa..ab787ceba 100644 --- a/src/core/song.cpp +++ b/src/core/song.cpp @@ -1500,6 +1500,13 @@ void song::removeController( Controller * _controller ) + +bool song::isLoadingProject() +{ + return m_loadingProject; +} + + #include "moc_song.cxx" From 6cf825ca996795a652f5bb7751b622e3ca175873 Mon Sep 17 00:00:00 2001 From: Wong Cho Ching Date: Wed, 29 Jan 2014 19:31:10 +0800 Subject: [PATCH 2/4] randomize PeakControllerEffect::m_effectId --- include/PeakController.h | 1 - plugins/peak_controller_effect/peak_controller_effect.cpp | 2 +- .../peak_controller_effect_controls.cpp | 4 ---- src/core/PeakController.cpp | 1 - 4 files changed, 1 insertion(+), 7 deletions(-) diff --git a/include/PeakController.h b/include/PeakController.h index b56c4c1a5..96240c6df 100644 --- a/include/PeakController.h +++ b/include/PeakController.h @@ -54,7 +54,6 @@ public: virtual QString nodeName() const; static PeakControllerEffectVector s_effects; - static int s_lastEffectId; public slots: diff --git a/plugins/peak_controller_effect/peak_controller_effect.cpp b/plugins/peak_controller_effect/peak_controller_effect.cpp index 4069c941b..0d8238262 100644 --- a/plugins/peak_controller_effect/peak_controller_effect.cpp +++ b/plugins/peak_controller_effect/peak_controller_effect.cpp @@ -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 ), diff --git a/plugins/peak_controller_effect/peak_controller_effect_controls.cpp b/plugins/peak_controller_effect/peak_controller_effect_controls.cpp index 740b2c416..18d66a417 100644 --- a/plugins/peak_controller_effect/peak_controller_effect_controls.cpp +++ b/plugins/peak_controller_effect/peak_controller_effect_controls.cpp @@ -62,10 +62,6 @@ void PeakControllerEffectControls::loadSettings( const QDomElement & _this ) m_amountMultModel.loadSettings( _this, "amountmult" ); int effectId = _this.attribute( "effectId" ).toInt(); - if( effectId > PeakController::s_lastEffectId ) - { - PeakController::s_lastEffectId = effectId; - } m_effect->m_effectId = effectId; if( m_effect->m_autoController && ( engine::getSong()->isLoadingProject() == true || presetPreviewPlayHandle::isPreviewing() == false ) ) diff --git a/src/core/PeakController.cpp b/src/core/PeakController.cpp index 7d5407df0..91d567a06 100644 --- a/src/core/PeakController.cpp +++ b/src/core/PeakController.cpp @@ -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; From 39a3b4c6cb660c3865f92bb55ca0b25cf1db6b38 Mon Sep 17 00:00:00 2001 From: Wong Cho Ching Date: Wed, 29 Jan 2014 19:57:13 +0800 Subject: [PATCH 3/4] set m_effectId to random value when it is not loaded from project. --- .../peak_controller_effect_controls.cpp | 17 +++++++++++++++-- plugins/zynaddsubfx/fltk/fltk-config | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/plugins/peak_controller_effect/peak_controller_effect_controls.cpp b/plugins/peak_controller_effect/peak_controller_effect_controls.cpp index 18d66a417..aaeec368a 100644 --- a/plugins/peak_controller_effect/peak_controller_effect_controls.cpp +++ b/plugins/peak_controller_effect/peak_controller_effect_controls.cpp @@ -61,8 +61,21 @@ void PeakControllerEffectControls::loadSettings( const QDomElement & _this ) m_absModel.loadSettings( _this, "abs" ); m_amountMultModel.loadSettings( _this, "amountmult" ); - int effectId = _this.attribute( "effectId" ).toInt(); - m_effect->m_effectId = effectId; + /*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 ) + { + m_effect->m_effectId = _this.attribute( "effectId" ).toInt(); + } + else + { + m_effect->m_effectId = rand(); + } if( m_effect->m_autoController && ( engine::getSong()->isLoadingProject() == true || presetPreviewPlayHandle::isPreviewing() == false ) ) { diff --git a/plugins/zynaddsubfx/fltk/fltk-config b/plugins/zynaddsubfx/fltk/fltk-config index 97ed9a514..f079deada 100755 --- a/plugins/zynaddsubfx/fltk/fltk-config +++ b/plugins/zynaddsubfx/fltk/fltk-config @@ -46,7 +46,7 @@ libdir=/usr/local/lib srcdir=. # compiler names -CC="gcc" +CC="cc" CXX="c++" # flags for C++ compiler: From 207bd9974f80eddc9fcaa1f65ebc0f2ef6cb1460 Mon Sep 17 00:00:00 2001 From: Wong Cho Ching Date: Wed, 29 Jan 2014 19:58:36 +0800 Subject: [PATCH 4/4] checkout fltk-config --- plugins/zynaddsubfx/fltk/fltk-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/zynaddsubfx/fltk/fltk-config b/plugins/zynaddsubfx/fltk/fltk-config index f079deada..97ed9a514 100755 --- a/plugins/zynaddsubfx/fltk/fltk-config +++ b/plugins/zynaddsubfx/fltk/fltk-config @@ -46,7 +46,7 @@ libdir=/usr/local/lib srcdir=. # compiler names -CC="cc" +CC="gcc" CXX="c++" # flags for C++ compiler: