Commit a537c5ee authored by Elvis Angelaccio's avatar Elvis Angelaccio
Browse files

Run CliInterface from the main thread

CLI-based plugins run their jobs in another process, so we can avoid to also
run them in another thread. This also fixes a race condition with the unit
tests.

Differential Revision: D1229
parent 3d698b97
......@@ -487,10 +487,6 @@ void ArchiveTest::testExtraction()
extractionJob->start();
eventLoop.exec();
// We need to wait for the QTemporaryDir in CliInterface::copyFiles() to autodelete itself.
// TODO: find a better solution. Possibly related to task T1771 ?
QTest::qSleep(250);
QFETCH(int, expectedExtractedEntriesCount);
int extractedEntriesCount = 0;
......
......@@ -310,10 +310,6 @@ void CliUnarchiverTest::testExtraction()
extractionJob->start();
eventLoop.exec();
// We need to wait for the QTemporaryDir in CliInterface::copyFiles() to autodelete itself.
// TODO: find a better solution. Possibly related to task T1771 ?
QTest::qSleep(500);
QFETCH(int, expectedExtractedEntriesCount);
int extractedEntriesCount = 0;
......
......@@ -799,11 +799,6 @@ void CliInterface::readStdout(bool handleAll)
return;
}
//if the process is still not finished (m_process is appearantly not
//set to NULL if here), then the operation should definitely not be in
//the main thread as this would freeze everything. assert this.
Q_ASSERT(QThread::currentThread() != QApplication::instance()->thread());
QByteArray dd = m_process->readAllStandardOutput();
m_stdOutData += dd;
......
......@@ -31,6 +31,7 @@
#include <QFileInfo>
#include <QRegularExpression>
#include <QThread>
#include <QTimer>
#include <KLocalizedString>
......@@ -106,7 +107,14 @@ void Job::start()
{
jobTimer.start();
m_isRunning = true;
d->start();
if (archiveInterface()->isCliBased()) {
// CLI-based interfaces run a QProcess, no need to use threads.
QTimer::singleShot(0, this, &Job::doWork);
} else {
// Run the job in another thread.
d->start();
}
}
void Job::emitResult()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment