# HG changeset patch # User Chris Cannam # Date 1591189070 -3600 # Node ID 7b6e18380e8fd6a83a7f17aa2aa099a5bc5444a7 # Parent 166d7a4c2cd657f91542e5eb95903bacfbf6eb0f Make it possible to check whether the transforms have been populated yet diff -r 166d7a4c2cd6 -r 7b6e18380e8f transform/TransformFactory.cpp --- a/transform/TransformFactory.cpp Wed Jun 03 13:57:37 2020 +0100 +++ b/transform/TransformFactory.cpp Wed Jun 03 13:57:50 2020 +0100 @@ -102,7 +102,9 @@ TransformFactory::UninstalledTransformsPopulateThread::run() { m_factory->m_populatingSlowly = true; - sleep(1); + while (!m_factory->havePopulated()) { + sleep(1); + } m_factory->populateUninstalledTransforms(); } @@ -324,6 +326,13 @@ return tr("Other"); } +bool +TransformFactory::havePopulated() +{ + MutexLocker locker(&m_transformsMutex, "TransformFactory::havePopulated"); + return m_transformsPopulated; +} + void TransformFactory::populateTransforms() { @@ -395,6 +404,12 @@ } m_transformsPopulated = true; + +#ifdef DEBUG_TRANSFORM_FACTORY + SVCERR << "populateTransforms exiting" << endl; +#endif + + emit transformsPopulated(); } void @@ -743,6 +758,8 @@ #ifdef DEBUG_TRANSFORM_FACTORY SVCERR << "populateUninstalledTransforms exiting" << endl; #endif + + emit uninstalledTransformsPopulated(); } Transform diff -r 166d7a4c2cd6 -r 7b6e18380e8f transform/TransformFactory.h --- a/transform/TransformFactory.h Wed Jun 03 13:57:37 2020 +0100 +++ b/transform/TransformFactory.h Wed Jun 03 13:57:50 2020 +0100 @@ -78,6 +78,13 @@ typedef std::map SearchResults; SearchResults search(QString keyword); SearchResults search(QStringList keywords); + + /** + * Return true if the transforms have been populated, i.e. a call + * to something like haveTransform() will return without having to + * do the work of scanning plugins + */ + bool havePopulated(); /** * Return true if the given transform is known. @@ -191,6 +198,10 @@ QString getStartupFailureReport() const { return m_errorString; } + +signals: + void transformsPopulated(); + void uninstalledTransformsPopulated(); protected: typedef std::map TransformDescriptionMap;