# HG changeset patch # User Chris Cannam # Date 1592841429 -3600 # Node ID 258e356b1a7bcef5cd307b603fe3f3f0166603d6 # Parent 9a288b9b7a72b968805f7e0eedaecd087de7ed95# Parent cb9209ef373a70b8f5c8ca3bc722fad504c590f9 Merge from branch startup-timing diff -r 9a288b9b7a72 -r 258e356b1a7b base/Debug.cpp --- a/base/Debug.cpp Thu Jun 18 15:42:19 2020 +0100 +++ b/base/Debug.cpp Mon Jun 22 16:57:09 2020 +0100 @@ -23,15 +23,16 @@ #include #include +#include -static SVDebug *svdebug = nullptr; -static SVCerr *svcerr = nullptr; +static std::unique_ptr svdebug = nullptr; +static std::unique_ptr svcerr = nullptr; static QMutex mutex; SVDebug &getSVDebug() { mutex.lock(); if (!svdebug) { - svdebug = new SVDebug(); + svdebug = std::make_unique(); } mutex.unlock(); return *svdebug; @@ -41,9 +42,9 @@ mutex.lock(); if (!svcerr) { if (!svdebug) { - svdebug = new SVDebug(); + svdebug = std::make_unique(); } - svcerr = new SVCerr(*svdebug); + svcerr = std::make_unique(*svdebug); } mutex.unlock(); return *svcerr; @@ -58,6 +59,8 @@ m_eol(true) { if (m_silenced) return; + + m_timer.start(); if (qApp->applicationName() == "") { cerr << "ERROR: Can't use SVDEBUG before setting application name" << endl; @@ -92,7 +95,10 @@ SVDebug::~SVDebug() { - if (m_stream) m_stream.close(); + if (m_stream) { + (*this) << "Debug log ends" << endl; + m_stream.close(); + } } QDebug & @@ -105,12 +111,12 @@ std::ostream & operator<<(std::ostream &target, const QString &str) { - return target << str.toStdString(); + return target << str.toUtf8().data(); } std::ostream & operator<<(std::ostream &target, const QUrl &u) { - return target << "<" << u.toString().toStdString() << ">"; + return target << "<" << u.toString() << ">"; } diff -r 9a288b9b7a72 -r 258e356b1a7b base/Debug.h --- a/base/Debug.h Thu Jun 18 15:42:19 2020 +0100 +++ b/base/Debug.h Mon Jun 22 16:57:09 2020 +0100 @@ -18,6 +18,7 @@ #include #include +#include #include "RealTime.h" @@ -46,7 +47,7 @@ if (m_silenced) return *this; if (m_ok) { if (m_eol) { - m_stream << m_prefix << " "; + m_stream << m_prefix << "/" << m_timer.elapsed() << ": "; } m_stream << t; m_eol = false; @@ -68,6 +69,7 @@ char *m_prefix; bool m_ok; bool m_eol; + QElapsedTimer m_timer; static bool m_silenced; }; diff -r 9a288b9b7a72 -r 258e356b1a7b transform/TransformFactory.cpp --- a/transform/TransformFactory.cpp Thu Jun 18 15:42:19 2020 +0100 +++ b/transform/TransformFactory.cpp Mon Jun 22 16:57:09 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 9a288b9b7a72 -r 258e356b1a7b transform/TransformFactory.h --- a/transform/TransformFactory.h Thu Jun 18 15:42:19 2020 +0100 +++ b/transform/TransformFactory.h Mon Jun 22 16:57:09 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;