Changeset View
Changeset View
Standalone View
Standalone View
libdiscover/resources/ResourcesModel.cpp
Context not available. | |||||
53 | , m_isFetching(false) | 53 | , m_isFetching(false) | ||
---|---|---|---|---|---|
54 | , m_initializingBackends(0) | 54 | , m_initializingBackends(0) | ||
55 | , m_currentApplicationBackend(nullptr) | 55 | , m_currentApplicationBackend(nullptr) | ||
56 | , m_allInitializedEmitter(new QTimer(this)) | ||||
56 | { | 57 | { | ||
57 | init(load); | 58 | init(load); | ||
58 | connect(this, &ResourcesModel::allInitialized, this, &ResourcesModel::slotFetching); | 59 | connect(this, &ResourcesModel::allInitialized, this, &ResourcesModel::slotFetching); | ||
Context not available. | |||||
64 | Q_ASSERT(!s_self); | 65 | Q_ASSERT(!s_self); | ||
65 | Q_ASSERT(QCoreApplication::instance()->thread()==QThread::currentThread()); | 66 | Q_ASSERT(QCoreApplication::instance()->thread()==QThread::currentThread()); | ||
66 | 67 | | |||
68 | m_allInitializedEmitter->setSingleShot(true); | ||||
69 | m_allInitializedEmitter->setInterval(0); | ||||
70 | connect(m_allInitializedEmitter, &QTimer::timeout, this, [this](){ | ||||
71 | if (m_initializingBackends == 0) | ||||
72 | emit allInitialized(); | ||||
73 | }); | ||||
74 | | ||||
67 | if(load) | 75 | if(load) | ||
68 | QMetaObject::invokeMethod(this, "registerAllBackends", Qt::QueuedConnection); | 76 | QMetaObject::invokeMethod(this, "registerAllBackends", Qt::QueuedConnection); | ||
69 | 77 | | |||
Context not available. | |||||
124 | // to send out the initialized signal. To ensure this happens, schedule it for the | 132 | // to send out the initialized signal. To ensure this happens, schedule it for the | ||
125 | // start of the next run of the event loop. | 133 | // start of the next run of the event loop. | ||
126 | if(m_initializingBackends==0) { | 134 | if(m_initializingBackends==0) { | ||
127 | QTimer::singleShot(0, this, [this](){ | 135 | m_allInitializedEmitter->start(); | ||
128 | if (m_initializingBackends == 0) | | |||
129 | emit allInitialized(); | | |||
130 | }); | | |||
131 | } else { | 136 | } else { | ||
132 | slotFetching(); | 137 | slotFetching(); | ||
133 | } | 138 | } | ||
Context not available. | |||||
155 | } else { | 160 | } else { | ||
156 | m_initializingBackends--; | 161 | m_initializingBackends--; | ||
157 | if(m_initializingBackends==0) | 162 | if(m_initializingBackends==0) | ||
158 | emit allInitialized(); | 163 | m_allInitializedEmitter->start(); | ||
159 | else | 164 | else | ||
160 | slotFetching(); | 165 | slotFetching(); | ||
161 | } | 166 | } | ||
Context not available. | |||||
216 | const auto backends = f.allBackends(); | 221 | const auto backends = f.allBackends(); | ||
217 | if(m_initializingBackends==0 && backends.isEmpty()) { | 222 | if(m_initializingBackends==0 && backends.isEmpty()) { | ||
218 | qCWarning(LIBDISCOVER_LOG) << "Couldn't find any backends"; | 223 | qCWarning(LIBDISCOVER_LOG) << "Couldn't find any backends"; | ||
219 | emit allInitialized(); | 224 | m_allInitializedEmitter->start(); | ||
220 | } else { | 225 | } else { | ||
221 | foreach(AbstractResourcesBackend* b, backends) { | 226 | foreach(AbstractResourcesBackend* b, backends) { | ||
222 | addResourcesBackend(b); | 227 | addResourcesBackend(b); | ||
Context not available. |