Mercurial > hg > sonic-visualiser
comparison transform/TransformFactory.cpp @ 118:b4110b17bca8
* Fix #1672407 confused by plugin-named files in cwd (or home?)
* Fix #1491848 crash when loading new file while transform plugin runs
* Fix #1502287 Background remains black after spectrogram layer deleted
* Fix #1604477 Replacing the main audio file silences secondary audio file
* Fix failure to initialise property box layout to last preference on startup
* Fix resample/wrong-rate display in Pane, ensure that right rate is chosen
if all current models have an acceptable rate even if previous main model
had a different one
* Fix "global zoom" broken in previous commit
* Some fixes to spectrogram cache area updating (makes spectrogram appear
more quickly, previously it had a tendency to refresh with empty space)
* Fixes to colour 3d plot normalization
author | Chris Cannam |
---|---|
date | Thu, 08 Mar 2007 16:53:08 +0000 |
parents | 58f21cf235c7 |
children | 006c90387f40 |
comparison
equal
deleted
inserted
replaced
117:8089a394829a | 118:b4110b17bca8 |
---|---|
715 } | 715 } |
716 | 716 |
717 Transform * | 717 Transform * |
718 TransformFactory::createTransform(TransformId identifier, Model *inputModel, | 718 TransformFactory::createTransform(TransformId identifier, Model *inputModel, |
719 const PluginTransform::ExecutionContext &context, | 719 const PluginTransform::ExecutionContext &context, |
720 QString configurationXml, bool start) | 720 QString configurationXml) |
721 { | 721 { |
722 Transform *transform = 0; | 722 Transform *transform = 0; |
723 | 723 |
724 QString id = identifier.section(':', 0, 2); | 724 QString id = identifier.section(':', 0, 2); |
725 QString output = identifier.section(':', 3); | 725 QString output = identifier.section(':', 3); |
742 std::cerr << "TransformFactory::createTransform: Unknown transform \"" | 742 std::cerr << "TransformFactory::createTransform: Unknown transform \"" |
743 << identifier.toStdString() << "\"" << std::endl; | 743 << identifier.toStdString() << "\"" << std::endl; |
744 return transform; | 744 return transform; |
745 } | 745 } |
746 | 746 |
747 if (start && transform) transform->start(); | 747 if (transform) transform->setObjectName(identifier); |
748 transform->setObjectName(identifier); | |
749 return transform; | 748 return transform; |
750 } | 749 } |
751 | 750 |
752 Model * | 751 Model * |
753 TransformFactory::transform(TransformId identifier, Model *inputModel, | 752 TransformFactory::transform(TransformId identifier, Model *inputModel, |
754 const PluginTransform::ExecutionContext &context, | 753 const PluginTransform::ExecutionContext &context, |
755 QString configurationXml) | 754 QString configurationXml) |
756 { | 755 { |
757 Transform *t = createTransform(identifier, inputModel, context, | 756 Transform *t = createTransform(identifier, inputModel, context, |
758 configurationXml, false); | 757 configurationXml); |
759 | 758 |
760 if (!t) return 0; | 759 if (!t) return 0; |
761 | 760 |
762 connect(t, SIGNAL(finished()), this, SLOT(transformFinished())); | 761 connect(t, SIGNAL(finished()), this, SLOT(transformFinished())); |
762 | |
763 m_runningTransforms.insert(t); | |
763 | 764 |
764 t->start(); | 765 t->start(); |
765 Model *model = t->detachOutputModel(); | 766 Model *model = t->detachOutputModel(); |
766 | 767 |
767 if (model) { | 768 if (model) { |
785 TransformFactory::transformFinished() | 786 TransformFactory::transformFinished() |
786 { | 787 { |
787 QObject *s = sender(); | 788 QObject *s = sender(); |
788 Transform *transform = dynamic_cast<Transform *>(s); | 789 Transform *transform = dynamic_cast<Transform *>(s); |
789 | 790 |
791 std::cerr << "TransformFactory::transformFinished(" << transform << ")" << std::endl; | |
792 | |
790 if (!transform) { | 793 if (!transform) { |
791 std::cerr << "WARNING: TransformFactory::transformFinished: sender is not a transform" << std::endl; | 794 std::cerr << "WARNING: TransformFactory::transformFinished: sender is not a transform" << std::endl; |
792 return; | 795 return; |
793 } | 796 } |
794 | 797 |
798 if (m_runningTransforms.find(transform) == m_runningTransforms.end()) { | |
799 std::cerr << "WARNING: TransformFactory::transformFinished(" | |
800 << transform | |
801 << "): I have no record of this transform running!" | |
802 << std::endl; | |
803 } | |
804 | |
805 m_runningTransforms.erase(transform); | |
806 | |
795 transform->wait(); // unnecessary but reassuring | 807 transform->wait(); // unnecessary but reassuring |
796 delete transform; | 808 delete transform; |
797 } | 809 } |
798 | 810 |
811 void | |
812 TransformFactory::modelAboutToBeDeleted(Model *m) | |
813 { | |
814 TransformSet affected; | |
815 | |
816 for (TransformSet::iterator i = m_runningTransforms.begin(); | |
817 i != m_runningTransforms.end(); ++i) { | |
818 | |
819 Transform *t = *i; | |
820 | |
821 if (t->getInputModel() == m || t->getOutputModel() == m) { | |
822 affected.insert(t); | |
823 } | |
824 } | |
825 | |
826 for (TransformSet::iterator i = affected.begin(); | |
827 i != affected.end(); ++i) { | |
828 | |
829 Transform *t = *i; | |
830 | |
831 t->abandon(); | |
832 | |
833 t->wait(); // this should eventually call back on | |
834 // transformFinished, which will remove from | |
835 // m_runningTransforms and delete. | |
836 } | |
837 } | |
838 |