Satisfy strange Qt thread-ownership requirements around QProcess objects

This commit is contained in:
baldurk
2019-01-11 16:03:35 +00:00
parent 8b28e0ed6d
commit f39be022a3
2 changed files with 8 additions and 0 deletions
@@ -110,6 +110,8 @@ static ShaderToolOutput RunTool(const ShaderProcessingTool &tool, QWidget *windo
QByteArray stdout_data;
QProcess process;
QThread *mainThread = QThread::currentThread();
LambdaThread *thread = new LambdaThread([&]() {
if(readStdin)
process.setStandardInputFile(input_file);
@@ -151,7 +153,12 @@ static ShaderToolOutput RunTool(const ShaderProcessingTool &tool, QWidget *windo
// QFile::remove(input_file);
QFile::remove(output_file);
QFile::remove(stdout_file);
process.moveToThread(mainThread);
});
thread->moveObjectToThread(&process);
thread->start();
ShowProgressDialog(window, QApplication::translate("ShaderProcessingTool",
+1
View File
@@ -305,6 +305,7 @@ public:
return true;
}
void moveObjectToThread(QObject *o) { o->moveToThread(m_Thread); }
bool isCurrentThread() { return QThread::currentThread() == m_Thread; }
};