forked from johanhelsing/qtws17-compositor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
processengine.cpp
34 lines (30 loc) · 1.07 KB
/
processengine.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "processengine.h"
#include <QDebug>
#include <QQmlEngine>
ProcessEngine::ProcessEngine(QObject *parent)
: QObject(parent)
{
}
Process *ProcessEngine::run(const QString &command, const QString &workingDirectory) {
auto theProcess = new Process(this); // probably leaky?
QProcessEnvironment env(QProcessEnvironment::systemEnvironment());
env.remove("LD_LIBRARY_PATH");
env.insert("QT_QPA_PLATFORM", "wayland-egl");
env.insert("WAYLAND_DISPLAY", "wayland-qt-presentation");
theProcess->setProcessEnvironment(env);
if (!workingDirectory.isEmpty())
theProcess->setWorkingDirectory(workingDirectory);
theProcess->start(command);
m_processes.append(theProcess);
QQmlEngine::setObjectOwnership(theProcess, QQmlEngine::CppOwnership);
return theProcess;
}
void ProcessEngine::killall()
{
qDebug() << "Killing all processes";
for (QProcess *process : qAsConst(m_processes)) {
qDebug() << "Killing" << process->program() << "(" << process->processId() << ")";
process->terminate();
}
m_processes.clear();
}