Commit Graph

43 Commits

Author SHA1 Message Date
Eike Ziller
462caec278 Utils: Small string fixes
Change-Id: I2fd6bf14b1cb35f61ced841e3deea011fd54ff03
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2024-02-26 08:56:41 +00:00
Marcus Tillmanns
d061e29dd3 Utils: Allow different codec for Process stdout and stderr
Change-Id: Ie6a3fb74a447a599c492e38ec83a2330f3cb4cd8
Reviewed-by: hjk <hjk@qt.io>
2024-02-23 16:02:45 +00:00
Jarek Kobus
00ba645fe1 ProcessBlockingInterface: Change signature of waitForSignal()
Change the arg to QDeadlineTimer type.

Change-Id: I7087648fd4f248b0b5024dc0d51d65171037934d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2024-01-23 07:09:33 +00:00
Jarek Kobus
63fc22e274 Process: Change signature of waitForXxx() functions
Change the arg to QDeadlineTimer type.

Change-Id: Id3dee0717e44130c16baf7925e5b06346a1a1ad1
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2024-01-23 07:09:22 +00:00
Jarek Kobus
665beaead9 Process: Change signature of setReaperTimeout()
Change the arg to std::chrono::milliseconds type.

Change-Id: I7b79fc318e2fd06971148038a31fecd4c1805a79
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2024-01-22 20:42:36 +00:00
Jarek Kobus
e98f6e31e7 Process: Change signature of exitMessage()
Change the last arg to std::chrono::milliseconds type.

Change-Id: Ifb818f76ee33e03997cb5b1dd17336248f401238
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2024-01-22 20:28:41 +00:00
Jarek Kobus
afc67468e6 Process: Get rid of setTimeoutS()
Add an extra arg to runBlocking() function instead.
Use std::chrono::seconds for timeout.

Change-Id: I7c3c21e8f26a2ccbed157d15083d6ef0b4cd2f7e
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2024-01-22 20:27:51 +00:00
Jarek Kobus
f6be85b1d2 Process: Refactor timeout handling
Rename ProcessResult::Hang into Canceled.

Change the behavior of the Process:
Whenever the terminate() or kill() is called, including
indirect calls through stop() or runBlocking()'s timeout,
mark the process result as Canceled.
In this way the Process running by a call to start()
may also finish with Canceled state. Before it was only
happening for processes started via runBlocking().

Adapt the runBlockingStdOut_data() test accordingly.

Get rid of ProcessInterface::m_canceledByUser field.
Use ProcessResult::Canceled state instead.

Fix existing 3 usages of m_canceledByUser field.
Use standarized exitMessage() method for them.

Add automatic measurement of process execution.
Introduce processDuration() getter.
Use it for reporting exitMessage() instead of timeoutS().

Change-Id: I1a68559ce844caef863a97a6b0577b0238011f70
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2024-01-22 20:27:38 +00:00
Jarek Kobus
886ac041e5 Process: Simplify the implementation of runBlocking(Off)
Extract the common part of handling the timeout into the
handleTimeout lambda.

Change-Id: I3c55c76cbc3d1217322c1b2a7002285bf2e649d3
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2024-01-22 16:29:54 +00:00
Jarek Kobus
2fe5b61aab Process: Read QTC_USE_QPROCESS just once
And store it in static variable.

Change-Id: I983ba4d23563ab412ba8db5e4ea4cc1b7a75dba7
Reviewed-by: hjk <hjk@qt.io>
2024-01-22 09:16:42 +00:00
Jarek Kobus
60eaa2c826 Process: Read QTC_MEASURE_PROCESS just once
And store it in static variable.

Change-Id: Ia630f63125088bff32a4d6df9de4c8279c8d8b34
Reviewed-by: hjk <hjk@qt.io>
2024-01-22 09:16:37 +00:00
Jarek Kobus
f200fe99a1 Process: Get rid of timeoutS()
The setter setTimeoutS() is going to be removed soon.
It's going to be replaced by the extra arg to runBlocking().

Change-Id: I60b8c952ba5e27e36183f8652aaa92059e08746e
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2024-01-21 18:37:04 +00:00
Jarek Kobus
6ed9552be2 Process: Introduce rawStdErr()
Complementary to rawStdOut().

Change-Id: I621b5b9858f775139a2c900f06812d9dd249d034
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2024-01-21 17:20:15 +00:00
Jarek Kobus
6fa2e00425 Process: Get rid of internal event loop field
It was only needed for runBlocking() in event loop mode.
Handle it locally from the runBlocking() function.

Change-Id: I6eb0830b223977bbf0fc73f0cdf4f3b4cab962b5
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2024-01-20 20:10:18 +00:00
Jarek Kobus
c86a19a56e Process: Fix stopping the process while message box is visible
When process finished while the message box querying for
a process to be stopped after a timeout was visible,
don't try to stop it and don't report a hang.

Change-Id: I74a819244a96d9e0209cabc6d58c0a1c4fe1ac31
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2024-01-20 20:10:12 +00:00
Jarek Kobus
767e11aa5d Process: Simplify timeout related internals
Get rid of two internal fields: m_hangTimerCount and m_waitingForUser.
Rename m_maxHangTimerCount into more meaningful m_timeoutInSeconds.
Fire single shot timers instead of a timer with interval.

Change-Id: I10890101273719f55a591eaecf818067aa5c503c
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2024-01-20 20:10:06 +00:00
Jarek Kobus
a475d89b5a Process: Get rid of debug enums
They are either not used or not usable.

Change-Id: Ib0e75624a3bd0d1fa98e45ffe1f5e15ef4db1217
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2024-01-20 17:31:36 +00:00
Jarek Kobus
443ce8e164 Process: Get rid of ProcessInterpreter
Move it locally to the only one user: VcsCommand.

For the future similar usages: use ProcessTask
and tweak the DoneResult inside TaskDoneHandler.

Change-Id: Icdffee7f1963f3ff377bfa6309e14bd1862a2c1f
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2024-01-17 13:27:55 +00:00
Jarek Kobus
312e50d29b Process: Introduce exitMessage() helper
This is going to be used for tweaked process result.

Change-Id: I1e4117dcd6145e4748a55c285b2546974a6e7d00
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2024-01-17 13:27:41 +00:00
Jarek Kobus
719d0f8335 Process: Rename processutils.{cpp,h} into processhelper.{cpp,h}
Make room for processutils.h which is going to contain
the exported stuff.

Change-Id: I87498c3a1d0708210aa970e2d45adaa0adb6e76a
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2024-01-17 08:42:59 +00:00
Marcus Tillmanns
06658d981c Utils: Fix (Q)Process::interrupt
Since switching to a QProcess based implementation a different
code path is used to interrupt processes (QProcessImpl::sendControlSignal, instead of ProcessLauncherImpl::sendControlSignal).

The QProcess path still used outdated ProcessHelper::interruptProcess.

This patch removes the old path and replaces it with the correct
"ProcessHelper::interruptPid" for QProcess based processes.

This also fixes GdbEngine::interruptInferior2 which could not interrupt
processes during "Attach to running server"

Change-Id: I9e1917100acf89c07cab0d9c687e57bb555d9d83
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2024-01-15 15:04:37 +00:00
Jarek Kobus
7802e475ce Process: Fix EventLoopMode::On
Queue the call to start() so that it's executed after the nested
event loop is started, otherwise it fails on Windows with QProcessImpl.

Fixes: QTCREATORBUG-30066
Change-Id: Ibb17ef0f668f52c05b26a521e18c94e637992ba5
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2024-01-13 13:38:49 +00:00
Jarek Kobus
8487df5130 Process: Ensure the application is of QGuiApplication type
Checking the existence of qGuiApp isn't enough, since the
implementation just static_casts qApp to QGuiApplication.

The issue might happen in autotests if some function calls
methods of QGuiApplication. The autotests instantiate just
QCoreApplication by default.

Change-Id: Id384fb21b2a2ad66fac59bf5de35668ce50df1d1
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2024-01-11 17:16:24 +00:00
Serg Kryvonos
c3a7279f05 Work on lambdas C++20 compatibility
Change-Id: I0d391c02ae1e1c5a1751b33ca7e83902e1cfe269
Reviewed-by: hjk <hjk@qt.io>
2023-12-13 13:24:22 +00:00
Jarek Kobus
a737ddd931 Process: Use GeneralProcessBlockingImpl for QProcess implementation
This should fix the Process::waitForReadyRead() when the data
appeared on stdErr channel and not on stdOut channel.

Amends ec722b9132

Change-Id: Ib9f361f4d1602487bdbbb735e55d0ad24fb5e4c3
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-12-07 10:47:59 +00:00
Jarek Kobus
659f0f000c TaskTree: Unify TaskInterface::done(DoneResult) signal
Change the argument of TaskInterface::done() signal
from bool into DoneResult. Make it consistent with
other TaskTree API.

Introduce toDoneResult(bool success) helper.

Change-Id: I7b3041d7c1ed0317c76adbc1fd37448231e85f82
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2023-11-17 09:44:20 +00:00
Jarek Kobus
a53dfaf623 Process: Switch the default implementation into QProcess
Task-number: QTCREATORBUG-28811
Change-Id: I5647b760998a80f59583b478a65de6d615e1ca55
Reviewed-by: hjk <hjk@qt.io>
2023-11-15 10:26:09 +00:00
Alessandro Portale
f96feadad0 Fix missing overrides and redundant virtual
Change-Id: Id2a247b6032602c2295d928067c2462d3f9b5221
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2023-11-14 14:27:45 +00:00
Leena Miettinen
61088bba69 Fix UI text capitalization, punctuation, and phrasing
Change-Id: I41951660a464601063e5cedd417db2cb7cd37e44
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-10-20 14:55:38 +00:00
Marcus Tillmanns
2a510011f1 Utils: Send start failed if no ProcessInterface
Change-Id: I38cdce9812bcec3240e3fb4f30a1dd266a5515e9
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2023-10-12 08:41:19 +00:00
Marcus Tillmanns
577b26bf1c Utils: Remove unused function
Change-Id: Ib6aadb180a1208f5ee124f788619afa213aa6823
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2023-10-06 06:18:47 +00:00
Marcus Tillmanns
e17866e283 Terminal: Show key when input is hidden
Change-Id: I5fca6a8c4f43ea2b95bad4df247b5df0abad521c
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2023-09-05 13:18:36 +00:00
Jarek Kobus
f4eb25ccec Process: Add setRunData() helper
It allows to set command/workingDir/env in one go.

Fix condition for setCommand() to match the one for setWorkingDir().

Change-Id: I0aa4639f3357c387a0fe8da321e94e34a3ea232d
Reviewed-by: hjk <hjk@qt.io>
2023-08-17 08:08:09 +00:00
Marcus Tillmanns
31f7ed44b6 FilePath: Use isSameDevice
Some places compared the scheme and host of a filepath to
decide whether its the same device. This is incorrect and
leads to false negatives. isSameDevice is the correct way
to decide whether two paths are from the same device.

Fixes: QTCREATORBUG-29474
Change-Id: Iced8f434dadb931f6595f47f95647b341c48d3aa
Reviewed-by: hjk <hjk@qt.io>
2023-08-08 13:19:35 +00:00
Marcus Tillmanns
def291f260 Terminal: Improve paste performance
Pasting large amounts of data on macos would block the App indefinitely.

The issue was a blocking call to ::write. The first fix for that was to
set O_NONBLOCK on the tty stdout fd. The second fix was to pass the
actual result of the write back to the caller so they can react to it.

In the TerminalSurface we now check if the write was successful and
if not we buffer the data and try again later.

Change-Id: Ibc92cce57fad88b5e9aa325197b42e17bec5e746
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-07-26 09:48:17 +00:00
Marcus Tillmanns
2edaf459bd Utils: Support relative path for PtyProcess
Change-Id: I8af96e51a4b75c192f5fab339449f4d07b1a040a
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2023-06-13 07:40:41 +00:00
Marcus Tillmanns
11ec14ebf4 Utils: Dont auto add sudo to all processes
Terminal processes need to add to the stub and not the target app,
so sudo is only automatically added for default processes.

The terminal interface is changed such that sudo is added to the stub.

Task-number: QTCREATORBUG-27519
Change-Id: Ife11e937644c4e946401a5b079e90fa64aee2c52
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2023-06-12 08:09:04 +00:00
Jarek Kobus
abb85b073a QScopeGuard: Make all usages of QScopeGuard consistent
Change-Id: Icfc35ecbdbdee8dadbb1b17789694093427c3ed9
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-06-07 10:35:01 +00:00
hjk
52db6f38f7 Utils: Replace two deprecated uses of .count()
Change-Id: I13d683b762c5093231e42c57d58ae322746d9922
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-06-06 14:35:46 +00:00
Leena Miettinen
48e2c66a4e Doc: Remove docs for Utils::SynchronousProcess
...that has been integrated into QtcProcess.

Change-Id: I39b6e4cb5d713d59345015b2a471cd4e6ef99f57
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-05-26 07:35:53 +00:00
Leena Miettinen
8c288bf05f Doc: Add "\inmodule QtCreator" to \class and \namespace docs
To get rid of QDoc warnings.

Change-Id: Idd39b7ae4327798c376f424c94d6617bcaee2258
Reviewed-by: hjk <hjk@qt.io>
2023-05-22 12:48:35 +00:00
Jarek Kobus
c75b59f9b4 Process: Rename QtcProcessPrivate -> ProcessPrivate
Rename the logging category for Process.
Fix inline comments accordingly.
Adapt warning/debug messages accordingly.

Change-Id: I2b1f0f558701def3afa3c1b04adf629833dba9e7
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2023-05-10 06:07:22 +00:00
Jarek Kobus
a0f6e8dc04 Utils: Rename qtcprocess.{cpp,h} -> process.{cpp,h}
Follows QtcProcess -> Process rename.

Change-Id: I97235a9a40cb7fd52944515b7ab878d96528f919
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-04 05:52:26 +00:00