Commit Graph

354 Commits

Author SHA1 Message Date
Orgad Shaneh
c72638ed74 QtcProcess: Introduce a way to track long-running blocking processes
...in the main thread.

Set QTC_PROCESS_THRESHOLD (in ms) to receive warnings for them.

Change-Id: Ia9e9c14b5ca339bfa2be82930518f988f56620c2
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2023-02-10 14:45:24 +00:00
Marcus Tillmanns
fb6fc2bde8 Utils: Add combine with device env option
Adds the option Environment::combineWithDeviceEnvironment. This allows
the linuxdevice to set it to false.

Without this option a deadlock would occur when the QtcProcess tries to
get the device environment and the device shell failed to start.
(e.g. because a required command is missing on the device).

Change-Id: I8f7550d0d90e989a339f27e993a836e67e910e33
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2023-02-01 17:24:07 +00:00
Alessandro Portale
4d6827dde9 Utils: Tr::tr
Change-Id: Ic03e20993f05fb5b49a12c891d86afb2c8e18e08
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2023-02-01 13:48:22 +00:00
Jarek Kobus
6758b5f69f Utils: Move QtcProcess::normalizeNewlines() into StringUtils
Change-Id: I515d2554497d5c27fd75e50c80ba373fbbe8dcb5
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-02-01 08:56:34 +00:00
hjk
e3f6eca25d Utils: Move some code from QtcProcess to its only user
This is not really nice/up-to-date either, but I'd rather
follow up on the user side.

Change-Id: I426fea3251b8984aea19788a16e574dccc3d057d
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2023-01-27 17:49:46 +00:00
hjk
dab859e776 Utils: Replace Environment.isValid() with .hasChanges()
That's closer to the intended semantics. The "other" use in docker
will be changed to an optional<Environment> as follow-up to
keep this here mechanical.

Change-Id: I43ef9da6c9c7731b28f9d6fab6413ce9c4f428b4
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-01-27 12:37:35 +00:00
Jarek Kobus
8e3a22329d QtcProcess: Add closeWriteChannel()
Change-Id: I080be230ec420ead2866f9481123125361e57033
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2023-01-24 08:48:12 +00:00
Marcus Tillmanns
a0d7b51cf5 Utils: Remove FilePath::toString from QtcProcess
Change-Id: I59df98547255bb5c282b190e0195323e0044214d
Reviewed-by: hjk <hjk@qt.io>
2023-01-12 07:14:42 +00:00
hjk
4ddd28ae22 Utils: Rename QtcProcess::readAllStandard* to readAllRawStandard*
... and re-use the old QtcProcess::readAllStandard* names for
a QString-returning 'decoded' version.

For now, only use that in 'full Utf8' cases, to stay bug-compatible,
the plan is, however, to employ the QTextCodecs we have already
in the channel buffers. That will be one-by-one, though.

Change-Id: Id209e0671920d4ea4197918e872f441254112d52
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-01-10 12:08:53 +00:00
Kai Köhne
56baf8c058 Remove GPL-3.0+ from license identifiers
Since we also license under GPL-3.0 WITH Qt-GPL-exception-1.0,
this applies only to a hypothetical newer version of GPL, that doesn't
exist yet. If such a version emerges, we can still decide to relicense...

While at it, replace (deprecated) GPL-3.0 with more explicit GPL-3.0-only

Change was done by running

  find . -type f -exec perl -pi -e "s/LicenseRef-Qt-Commercial OR GPL-3.0\+ OR GPL-3.0 WITH Qt-GPL-exception-1.0/LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0/g" {} \;

Change-Id: I5097e6ce8d10233993ee30d7e25120e2659eb10b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-01-06 11:15:13 +00:00
Cristian Adam
68eb983b5d Revert "Utils: Remove some fallback code that uses a full remote env"
This reverts commit 192605f01c.

Reason for revert: breaks tst_utils_deviceshell

Change-Id: Iafae2aa8da09c23746dccd170e10ea07ffb71ed3
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-12-20 06:33:43 +00:00
hjk
192605f01c Utils: Remove some fallback code that uses a full remote env
... when an empty environment was given. At least for opening
a terminal in the remote linux device setup dialog this was
intentional as the passed env was meant to be the 'diff' that's
then passed via the SSH commandline, which then - independently -
broke due to not properly escaping of too complex values.

Right now, neither way is really correct. The path forward seems
to move towards 'EnvironmentChange' in general, but this will
take some time.

Change-Id: I86ca4da4b30b7b463583e002f2c19d6e6c5541e6
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-12-15 16:09:11 +00:00
Jarek Kobus
ef6020ae0f QtcProcess: Set Starting state a bit later
To avoid resetting it back again to NotRunning
in case an assert triggered.

Change-Id: I4ba52bb64fd3b782013cf47d9149bef7f8a231af
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2022-11-29 12:49:24 +00:00
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