Changeset View
Changeset View
Standalone View
Standalone View
src/file/extractorprocess.cpp
Show All 25 Lines | |||||
26 | using namespace Baloo; | 26 | using namespace Baloo; | ||
27 | 27 | | |||
28 | ExtractorProcess::ExtractorProcess(QObject* parent) | 28 | ExtractorProcess::ExtractorProcess(QObject* parent) | ||
29 | : QObject(parent) | 29 | : QObject(parent) | ||
30 | , m_extractorPath(QStandardPaths::findExecutable(QStringLiteral("baloo_file_extractor"))) | 30 | , m_extractorPath(QStandardPaths::findExecutable(QStringLiteral("baloo_file_extractor"))) | ||
31 | , m_extractorProcess(this) | 31 | , m_extractorProcess(this) | ||
32 | { | 32 | { | ||
33 | connect(&m_extractorProcess, &QProcess::readyRead, this, &ExtractorProcess::slotIndexingFile); | 33 | connect(&m_extractorProcess, &QProcess::readyRead, this, &ExtractorProcess::slotIndexingFile); | ||
34 | connect(&m_extractorProcess, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), | ||||
35 | [=](int exitCode, QProcess::ExitStatus exitStatus) | ||||
36 | { | ||||
37 | if (exitStatus == QProcess::CrashExit) { | ||||
38 | Q_EMIT failed(); | ||||
39 | } | ||||
40 | }); | ||||
41 | | ||||
42 | m_extractorProcess.setProgram(m_extractorPath); | ||||
34 | m_extractorProcess.setProcessChannelMode(QProcess::ForwardedErrorChannel); | 43 | m_extractorProcess.setProcessChannelMode(QProcess::ForwardedErrorChannel); | ||
35 | m_extractorProcess.start(m_extractorPath, QStringList(), QIODevice::Unbuffered | QIODevice::ReadWrite); | 44 | m_extractorProcess.start(); | ||
36 | m_extractorProcess.waitForStarted(); | | |||
37 | m_extractorProcess.setReadChannel(QProcess::StandardOutput); | | |||
38 | } | 45 | } | ||
apol: Shouldn't it check the exitCode too? | |||||
the exitCode is "only valid for normal exits" (Qt docu), and 0 otherwise. bruns: the exitCode is "only valid for normal exits" ([[ http://doc.qt.io/qt-5/qprocess. | |||||
39 | 46 | | |||
40 | ExtractorProcess::~ExtractorProcess() | 47 | ExtractorProcess::~ExtractorProcess() | ||
41 | { | 48 | { | ||
42 | m_extractorProcess.close(); | 49 | m_extractorProcess.close(); | ||
43 | } | 50 | } | ||
44 | 51 | | |||
52 | void ExtractorProcess::start() | ||||
53 | { | ||||
54 | m_extractorProcess.start(QIODevice::Unbuffered | QIODevice::ReadWrite); | ||||
55 | m_extractorProcess.waitForStarted(); | ||||
apol: Do you really need to waitForStarted? | |||||
Copied from the old code. Should not hurt, as done from a runner thread. bruns: Copied from the old code. Should not hurt, as done from a runner thread. | |||||
56 | m_extractorProcess.setReadChannel(QProcess::StandardOutput); | ||||
57 | } | ||||
58 | | ||||
45 | void ExtractorProcess::index(const QVector<quint64>& fileIds) | 59 | void ExtractorProcess::index(const QVector<quint64>& fileIds) | ||
46 | { | 60 | { | ||
47 | Q_ASSERT(m_extractorProcess.state() == QProcess::Running); | 61 | Q_ASSERT(m_extractorProcess.state() == QProcess::Running); | ||
48 | Q_ASSERT(!fileIds.isEmpty()); | 62 | Q_ASSERT(!fileIds.isEmpty()); | ||
49 | 63 | | |||
50 | QByteArray batchData; | 64 | QByteArray batchData; | ||
51 | 65 | | |||
52 | quint32 batchSize = fileIds.size(); | 66 | quint32 batchSize = fileIds.size(); | ||
Show All 37 Lines |
Shouldn't it check the exitCode too?