Port to Qt 6's absence of QProcess::setupChildProcess

Change-Id: I9709abb1c3734e10a7defffd1607e5b3fd46af0e
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Thiago Macieira
2020-04-21 10:25:54 -07:00
parent 7e6e02eb08
commit 6a66ced594
5 changed files with 40 additions and 6 deletions

View File

@@ -678,6 +678,10 @@ QtcProcess::QtcProcess(QObject *parent)
static int qProcessProcessErrorMeta = qRegisterMetaType<QProcess::ProcessError>();
Q_UNUSED(qProcessExitStatusMeta)
Q_UNUSED(qProcessProcessErrorMeta)
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) && defined(Q_OS_UNIX)
setChildProcessModifier([this]() { niceChildProcess(); });
#endif
}
void QtcProcess::setUseCtrlCStub(bool enabled)
@@ -1220,18 +1224,25 @@ QString QtcProcess::expandMacros(const QString &str, AbstractMacroExpander *mx,
return ret;
}
void QtcProcess::setupChildProcess()
{
#if defined Q_OS_UNIX
void QtcProcess::niceChildProcess()
{
// nice value range is -20 to +19 where -20 is highest, 0 default and +19 is lowest
if (m_lowPriority) {
errno = 0;
if (::nice(5) == -1 && errno != 0)
perror("Failed to set nice value");
}
#endif
}
# if QT_VERSION < QT_VERSION_CHECK(6,0,0)
void QtcProcess::setupChildProcess()
{
niceChildProcess();
QProcess::setupChildProcess();
}
# endif
#endif
bool QtcProcess::ArgIterator::next()
{