Changeset View
Changeset View
Standalone View
Standalone View
src/file/filecontentindexer.cpp
Show First 20 Lines • Show All 75 Lines • ▼ Show 20 Line(s) | 70 | #endif | |||
---|---|---|---|---|---|
76 | bool hadErrors = false; | 76 | bool hadErrors = false; | ||
77 | connect(&process, &ExtractorProcess::failed, &loop, [&hadErrors, &loop]() { hadErrors = true; loop.quit(); }); | 77 | connect(&process, &ExtractorProcess::failed, &loop, [&hadErrors, &loop]() { hadErrors = true; loop.quit(); }); | ||
78 | 78 | | |||
79 | QElapsedTimer timer; | 79 | QElapsedTimer timer; | ||
80 | timer.start(); | 80 | timer.start(); | ||
81 | 81 | | |||
82 | process.index(idList); | 82 | process.index(idList); | ||
83 | loop.exec(); | 83 | loop.exec(); | ||
84 | batchSize = idList.size(); | ||||
84 | 85 | | |||
85 | // QDbus requires us to be in object creation thread (thread affinity) | | |||
86 | // This signal is not even exported, and yet QDbus complains. QDbus bug? | | |||
87 | QMetaObject::invokeMethod(this, "newBatchTime", Qt::QueuedConnection, Q_ARG(uint, timer.elapsed())); | | |||
88 | #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) | 86 | #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) | ||
89 | if (hadErrors && !m_stop.load()) { | 87 | if (hadErrors && !m_stop.load()) { | ||
90 | #else | 88 | #else | ||
91 | if (hadErrors && !m_stop.loadRelaxed()) { | 89 | if (hadErrors && !m_stop.loadRelaxed()) { | ||
92 | #endif | 90 | #endif | ||
93 | if (idList.size() == 1) { | 91 | if (batchSize == 1) { | ||
94 | auto failedId = idList.first(); | 92 | auto failedId = idList.first(); | ||
95 | m_provider->markFailed(failedId); | 93 | m_provider->markFailed(failedId); | ||
96 | batchSize = m_batchSize; | 94 | batchSize = m_batchSize; | ||
97 | } else { | 95 | } else { | ||
98 | batchSize = idList.size() / 2; | 96 | batchSize /= 2; | ||
99 | } | 97 | } | ||
100 | process.start(); | 98 | process.start(); | ||
99 | } else { | ||||
100 | auto elapsed = timer.elapsed(); | ||||
101 | QMetaObject::invokeMethod(this, | ||||
102 | [this, elapsed, batchSize] { newBatchTime(elapsed, batchSize); }, | ||||
103 | Qt::QueuedConnection); | ||||
101 | } | 104 | } | ||
102 | } | 105 | } | ||
103 | QMetaObject::invokeMethod(this, "done", Qt::QueuedConnection); | 106 | QMetaObject::invokeMethod(this, &FileContentIndexer::done, Qt::QueuedConnection); | ||
104 | } | 107 | } | ||
105 | 108 | | |||
106 | void FileContentIndexer::slotStartedIndexingFile(const QString& filePath) | 109 | void FileContentIndexer::slotStartedIndexingFile(const QString& filePath) | ||
107 | { | 110 | { | ||
108 | m_currentFile = filePath; | 111 | m_currentFile = filePath; | ||
109 | if (!m_registeredMonitors.isEmpty()) { | 112 | if (!m_registeredMonitors.isEmpty()) { | ||
110 | Q_EMIT startedIndexingFile(filePath); | 113 | Q_EMIT startedIndexingFile(filePath); | ||
111 | } | 114 | } | ||
Show All 30 Lines |