Commit Graph

341 Commits

Author SHA1 Message Date
Eike Ziller
ae67799eb3 Merge remote-tracking branch 'origin/9.0'
Change-Id: I2123e09f75199a63af6e8505fb8889e7f9d025d2
2022-11-16 09:40:34 +01:00
hjk
779dc52a97 Utils: Fix interrupting local processes on *nix
Change-Id: I6e722379ad62c98d1e8e6d445c1eeea171ff141b
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-11-16 08:04:01 +00:00
Jarek Kobus
c49de14c9d Utils: Introduce TaskTree and Tasking namespace
The TaskTree class is responsible for running async task tree
structure defined in a declarative way.

Change-Id: Ieaf706c7d2efdc8b431a17b2db8b28bf4b7c38e5
Reviewed-by: hjk <hjk@qt.io>
2022-11-09 17:06:31 +00:00
Orgad Shaneh
7edf743583 Merge remote-tracking branch 'origin/9.0'
Change-Id: I5e6cfc111941f9609285e1b802121644fa8cdaac
2022-10-19 09:12:14 +03:00
Jarek Kobus
d85dd1962b QtcProcess: Disconnect from ProcessInterface signals
... on destruction.

Change-Id: I6751e1ba2999f506e85ebb697a8a1c7152ea9abb
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2022-10-18 16:48:43 +00:00
Jarek Kobus
f0628c9b7d ProcessResultData: Add a flag for forceful close
Whenever user calls terminate(), kill() or stop() this
sets the m_canceledByUser flag to true inside result().

Change-Id: Ic99642762868fd0a28193caa8ea05e165cb2a277
Reviewed-by: hjk <hjk@qt.io>
2022-10-12 08:10:27 +00:00
Jarek Kobus
07ca7f7b99 Introduce ProcessProgress
This is extracted separate object out of VcsCommand.
It's responsible for showing progress of the running
process. It's able to cancel the running process
automatically after pressing a small 'x' indicator on
progress panel. In this case the QtcProcess::stop()
method is being called.

Change-Id: I9fa94fd047638f76909356ae4023852349be3a06
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-10-12 07:44:41 +00:00
Jarek Kobus
39258f5522 QtcProcess: Get rid of setResult()
This isn't meant to be called publicly.

Change-Id: I1a5e5325ac268e1bbfcc34c529cfc3c7e628243c
Reviewed-by: hjk <hjk@qt.io>
2022-10-11 12:34:48 +00:00
Jarek Kobus
f5f3bbcc59 Use more Utils::isMainThread()
Change-Id: Ia3c6f6dca53c5d7487b0813de16f06c52af47aa5
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-10-11 07:34:12 +00:00
Jarek Kobus
77a140c581 QtcProcess: Introduce TextChannelMode and textOnChannel signals
This is alternative to setStd[Out/Err](Line)Callback()
methods. In this way there may be many clients connected
to textOnStandard[Output/Error]() signals. This should
also simplify handling the lifetime of user callback.

Change-Id: If82baa1f3f9c432ed431926619b9bbf11d770a84
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-10-10 09:47:06 +00:00
Marc Mutz
8eb4d52342 Port from qAsConst() to std::as_const()
We've been requiring C++17 since Qt 6.0, and our qAsConst use finally
starts to bother us (QTBUG-99313), so time to port away from it
now.

Since qAsConst has exactly the same semantics as std::as_const (down
to rvalue treatment, constexpr'ness and noexcept'ness), there's really
nothing more to it than a global search-and-replace.

Task-number: QTBUG-99313
Change-Id: I88edd91395849574436299b8badda21bb93bea39
Reviewed-by: hjk <hjk@qt.io>
2022-10-07 13:47:53 +00:00
Jarek Kobus
b2ee86ba03 QtcProcess: Small cleanup
Change-Id: Ib3c913185b01ad3f81e883bd3013ccb95a863485
Reviewed-by: hjk <hjk@qt.io>
2022-10-06 15:39:03 +00:00
Jarek Kobus
512edfc60d QtcProcess: Consolidate the log debug code
Reuse starting() signal for doing initial debug printout.
Keep dynamic properties in QtcProcessPrivate only, so
no need for passing it.

Change-Id: I170ea96c37e1b9904037851799316de629bfb86e
Reviewed-by: hjk <hjk@qt.io>
2022-10-06 15:38:52 +00:00
Jarek Kobus
239788c121 QtcProcess: Simplify emitting guarded signals
Avoid code repetition.

Change-Id: I259cb3e9396c0c84dbc63e7929f949580070c382
Reviewed-by: hjk <hjk@qt.io>
2022-10-06 15:12:40 +00:00
Jarek Kobus
db5e3555ac QtcProcess: Add starting() signal
Will be useful for VcsCommand controlling.

Change-Id: I6e0199c7a45948526cfd916907b098472b78219c
Reviewed-by: hjk <hjk@qt.io>
2022-10-06 13:39:46 +00:00
Jarek Kobus
5b0c2bcbf8 QtcProcess: Fix stdErr() assert
The keepRawData field may be false only after calling
setStdErrLineCallback(). In all current usages (7 places)
we don't call stdErr() nor cleanedStdErr().
VcsCommand was using setStdErrCallback() so that did not
change the keepRawData to false.

It looks like currently it should be safe to fix this assert.

Amends 4000819262

Change-Id: I9f8627166d194579c5a0fe13d241ff37aecac47c
Reviewed-by: hjk <hjk@qt.io>
2022-09-19 10:31:02 +00:00
Jarek Kobus
c94382aea5 QtcProcess: Add an assert about restarting from signal handler
Change-Id: I66ede2c8d726929ceb31a456eb8692e051c1b09e
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-09-09 11:57:57 +00:00
Eike Ziller
e77c90469b Utils: Use qtcEnvironmentVariable* instead of qEnvironmentVariable*
And instead of qgetenv.
Takes Qt Creator's setting at "Environment > System > Environment" into
account, which makes it easier on some platforms to set them (e.g.
macOS), can be configured differently in different settings paths, and
potentially can be changed at runtime (depending on usage).

Change-Id: I50e457bab2d3495e5c69676fe1a0257a5fea3e52
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2022-09-01 13:03:05 +00:00
Lucie Gérard
a7956df3ca Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.

Task-number: QTBUG-67283
Change-Id: I708fd1f9f2b73d60f57cc3568646929117825813
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-08-26 12:27:18 +00:00
Jarek Kobus
60302debd7 Move ShellCommand into VcsBase plugin
Rename it to VcsCommand. Move also ShellCommandPage into
VcsBase plugin.

Change-Id: I335ac47e3090f2be497643ebcda0eaad2987ac81
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>
2022-08-01 14:33:06 +00:00
Jarek Kobus
74ea4dc07d Drop Qt5: Utils: Get rid of QOverload
Change-Id: I864bfb18668fd325badd34003adf494c7924f86b
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2022-07-20 10:30:25 +00:00
Jarek Kobus
f330a7b1e9 QtcProcess: Make timeoutS a default arg of 30 seconds
Change-Id: Id11911e74ede109b49583d82592b333ad577e8ee
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-07-11 10:21:46 +00:00
Jarek Kobus
61258bd658 QtcProcess: Get rid of unneeded arg from readDataFromProcess()
Change-Id: Ifecf7b4a9668bc362e454a6e5084eb1d7308e4eb
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-07-11 10:21:38 +00:00
Marcus Tillmanns
8a7a4fce6c docker: Add dockercli setting
Change-Id: I46fada555d697007042d823ef1cad0658be98e22
Reviewed-by: hjk <hjk@qt.io>
2022-07-04 12:21:00 +00:00
Jarek Kobus
e5942932f4 QtcProcess: Remove unused signals
Change-Id: I5ceca4310de670dc52542607c549a159cbe697f9
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-06-28 17:30:23 +00:00
Eike Ziller
92c74abbf1 Fix lupdate issues
Change-Id: I7256c8aff5eb77b264b76ba24e79c26ab2924e84
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>
2022-06-27 07:05:22 +00:00
Jarek Kobus
9fde8511e2 QtcProcess: Be idle when incoming data is empty
Don't forward and flush empty data

Change-Id: Idb153695d7eb62905c000b70efdfb0c68f0df9ad
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-06-24 09:41:10 +00:00
Jarek Kobus
e49e0f87cd QtcProcess: Connect to done() signal instead of finished()
Change-Id: Ie9005e2dc225907e46bb46086a663763b58c5152
Reviewed-by: hjk <hjk@qt.io>
2022-06-22 13:00:19 +00:00
hjk
f7e9623369 Utils: Remove one spurious static function from QtcProcess
The next one could probably be merged into FilePath::searchInPath

Change-Id: If32fe77fb19b628a44d212bb8420443bd4f04899
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-06-20 13:35:12 +00:00
David Schulz
153ff77a6b Utils: use cleaned stdout all over the place again
Amends 5ee880ce5e

Change-Id: Ie0202db7d8455372c3697087d9571db6706b45a1
Reviewed-by: hjk <hjk@qt.io>
2022-06-17 13:04:42 +00:00
hjk
5ee880ce5e Utils: Add a few convenience functions to work with process output
Change-Id: I45acea77ccfdc15b1be9693c1658890865383c16
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-06-16 14:43:21 +00:00
hjk
53896ed295 Utils: Dissolve QtcProcess::stopProcess
Change-Id: Ife07f34ffc69cd30984276464bd89738c2a71311
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-06-16 09:17:23 +00:00
Jarek Kobus
0b2899215f Introduce ProcessBlockingInterface
This replaces the ProcessInterface::waitFor...() methods.
It's not obligatory to provide this interface when
implementing ProcessInterface subclass. In this case
generic blocking implementation will be used.

The generic implementation usually isn't as efficient as
the custom one, however, for some sophisticated implementations
of process interface, like e.g. SshProcessInterface, providing
custom implementation is really difficult and error prone.

That's why we try to keep a balance: we provide two custom
implementations for QProcessImpl and for ProcessLauncherImpl,
as they are relatively easy to implement, and rely on
generic implementation for others.

Change-Id: Ifc8bd354479ec67b2e8f74f1510f8de8883e9b94
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-06-14 09:45:28 +00:00
Jarek Kobus
de6fd1b1b1 QtcProcess: Refactor killTimer
Before we were installing the timer inside the process
interface handler. The issue was that when the handler was
moved into another thread, the timer was restarted (that's
what happens with all timers when they are moved into another
thread).

The fix is to keep the timer inside the caller thread and
detect inside waitForSignal() whether a timer was started.
In case the remaining time for kill timer is less than
a timeout for waitForSignal, we split the waiting into two
parts and execute kill() in meantime.

Change-Id: I2c18805593fe2f73d816cce40dbb45bf58a50715
Reviewed-by: hjk <hjk@qt.io>
2022-06-08 12:13:13 +00:00
Jarek Kobus
224f580924 Move SignalType into processinterface.h
Rename it into ProcessSignalType. It's going to be
used in new interface.

Change-Id: Ifbab8bbb601f14ecbf65d940e524c558d5f1d7a1
Reviewed-by: hjk <hjk@qt.io>
2022-06-08 12:03:29 +00:00
Jarek Kobus
cf47ad361d QtcProcess: Get rid of NoSignal synthetic value
Refactor flushing methods.

Change-Id: I1b98de58e8ddacfa5ff7e1627c5011c0bd207a8b
Reviewed-by: hjk <hjk@qt.io>
2022-06-08 12:03:22 +00:00
Jarek Kobus
493573b879 QtcProcess: Make reaper timeout customizable
Add a setter and getter for reaper timeout. This makes it
possible to customize the timeout for the reaper after which it
should call kill() when previous terminate() was unsuccessful.

This setting is also used for QtcProcess::stop().

Change-Id: I653a3ad107ae4173bb8254c85cfc07886bf6a9c6
Reviewed-by: hjk <hjk@qt.io>
2022-06-08 11:21:42 +00:00
Jarek Kobus
c7c6b70cbe QtcProcess: Add stop() method
This method works like close() with the difference that
after calling stop() we are still going to receive
signals from QtcProcess, especially done() signal.

This method isn't blocking, so a calling it is fast.
Just after calling this method QtcProcess is still
in the same state and done() signal should be delivered
asynchronously. It's safe to call waitForFinished() after
calling stop() with the desired timeout.

Calling stop() in a row with waitForFinished() is a good
substitute for stopProcess().

Change-Id: I1df55beb7f89c9b73203c9ba4bc276a4060600a5
Reviewed-by: hjk <hjk@qt.io>
2022-06-03 10:49:06 +00:00
hjk
d76458a8b6 Utils: Replace Environment::size() check by some isValid() function
More descriptive, and later implementable without full expansion.

Change-Id: Ic3b17ea0b07273f292827a7b63e7695b4bd1cf23
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-06-03 09:42:26 +00:00
Jarek Kobus
edbec09719 QtcProcess: Don't merge ready read signals
Fix it also for general waitForSignal() implementation.

Amends fc2f3983bc

Task-number: QTCREATORBUG-27578
Change-Id: Ifb9ebbd5c3fa2c900bae924aefccb713983b1697
Reviewed-by: hjk <hjk@qt.io>
2022-06-02 16:06:50 +00:00
Jarek Kobus
f301bb3f97 QtcProcess: Fix behavior of kill()
Make it behave more like QProcess::kill().

Before, when QtcProcess::kill() has been called,
the process launcher was putting the process into the
reaper and notified the QtcProcess that it was already killed,
while in fact it could still be alive for a while since it
was in reaper's hands. The current fix makes the behavior
similar to what QProcess does when calling kill(). So now,
in case of a call to kill() the process isn't put into the reaper yet,
so it has a chance to report back the finished signal when the
process was really stopped.

We still use the old behavior of putting the running process
into the reaper in case of a call to QtcProcess::close() and
when d'tor of QtcProcess was called. We don't report back the
confirmation about putting the process into the reaper, since
close() is always called from ProcessLauncherImpl d'tor, so
there is no one to receive this confirmation anyway.

Change-Id: I665e7c8fb1a391dda30c86389259961e715926d6
Reviewed-by: hjk <hjk@qt.io>
2022-06-01 10:32:22 +00:00
Jarek Kobus
ed40753ed1 Utils: Drop unused headers [I-Z]
Round 2 - focus on sources.
For classes with initial in range [I-Z].
Try to keep the same separators between different kind of headers.

Change-Id: I8a7ab99bab8120ee72cda6433ee3dc6f260a4d76
Reviewed-by: hjk <hjk@qt.io>
2022-05-25 07:49:25 +00:00
Jarek Kobus
304ab10642 Utils: More forward declarations / drop unused headers [P-R]
Round 1 - focus on headers.
For classes with initial in range [P-R].
Try to keep the same separators between different kind of headers.

Change-Id: I01fb80b93164a7fe4c0bd2cd8f9e4f27523efefa
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-05-25 07:18:44 +00:00
Jarek Kobus
f9433c79b7 QtcProcess: Use Utils::Guard instead of self made substitute
Change-Id: I36b6db25998b5c34c2c96cfb5dc8c60537dbb7b6
Reviewed-by: hjk <hjk@qt.io>
2022-05-24 11:46:38 +00:00
Jarek Kobus
0675fe05b9 QtcProcess: Guard emission of done() signal
Add a missing guard for emitting done signal. It was overlooked
during QtcProcess devirtualization.

Amends a717ff71f4

Change-Id: I62c38d2ba9f3e437b5ef088b8362e97d16e576e4
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2022-05-20 08:18:55 +00:00
Jarek Kobus
0a8dbaf153 Utils lib: Remove unneeded includes from cpp files
It's a result of a team work consisting of yellow triangle and me.

Change-Id: I8b4812766da70e0785ae71bf0cb71357379e2514
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2022-05-19 12:37:20 +00:00
Cristian Adam
8be05ca745 Utils: Remove Debug restriction for useCtrlCStub
process_ctrlc_stub doesn't generate a Ctrl+C event sent via
GenerateConsoleCtrlEvent for the child process to terminate.

So the Debug restriction to workaround QTCREATORBUG-11995 is
no longer needed.

Change-Id: Iafc8b51bce17432c80b0be0c4084978abc1c909f
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2022-05-11 12:35:15 +00:00
hjk
e657bc8781 Utils: Introduce QtcProcess::controlEnvironment()
... and drop QtcProcess::removeEnvironment()

This shifts the meaning of the unqualified QtcProcess::environment()
to always refer to (possibly remote) "main" process this QtcProcess
wraps. The controlEnvironment is now referring to secondary helper
processes (if any...) typically(?) running on the host system.

This helps to avoid local/remote distinctions in some places.

Change-Id: Ib7cd15dd226617484b5358acd7deaed29e751883
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-05-10 09:53:53 +00:00
Jarek Kobus
6455d7fcf3 QtcProcess: Make the class final
Currently, as a result of many refactorings, the QtcProcess
is designed so that if you want to customize the behavior
you should implement custom ProcessInterface subclass.
Adding virtual methods directly to QtcProcess caused tons of
unpredicted side effects and nasty bugs, which were hard to
track and hard to fix, as provided fixes were usually fixing
particular case while introducing regressions in not related
code paths.

Consider also aggregating QtcProcess object instead of
deriving from it when some additional methods are required.

This patch removes the last virtual methods from QtcProcess API
and makes the class final in order to prevent from adding
any new virtual methods to this class in the future.

This commit message should make it clear that having subclasses
of QtcProcess is not a desired design. It's a post-mortem
conclusion. So: don't derive from QtcProcess - we mean it!

Change-Id: I1e43ed45be326b366422fd7db6e05ba48ea5fb98
Reviewed-by: hjk <hjk@qt.io>
2022-05-09 07:42:29 +00:00
hjk
ef346779eb Utils: Use some helper function in QtcProcess for common code
Change-Id: Iffa720f5c6b3c86ad80c92566fbe00465d3ed7a4
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-05-06 09:21:54 +00:00