Commit Graph

341 Commits

Author SHA1 Message Date
Jarek Kobus
fdc8193f13 ProcessInterface: Drop ProcessMode from c'tor
Drop it also from registerHandle() methods, as it wasn't
used there.

Change-Id: I34b72c38368b82f22d73314fe3cd429ed43cadbc
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-18 08:29:24 +00:00
Alessandro Portale
74643556f9 Utils: Print out QtcProcess number in result debug log
That makes it easier to understand which result belongs to which
process. And make the result output a 1-liner in the case of logging,
which makes filtering easier.

Change-Id: I6da84d28fe2269d2d6dfe6f5a1d300faf5697ca1
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-02-17 17:07:10 +00:00
Jarek Kobus
ae36fd943a ProcessInterface: Drop arguments from finished() signal
Make the API more similar to QtcProcess API.

Change-Id: If62051908b7974008bebda21dd288b02e7a772f3
Reviewed-by: hjk <hjk@qt.io>
2022-02-17 16:58:19 +00:00
Jarek Kobus
531e24892b Fix starting remote process in terminal
SshDeviceProcess::start() is overridden and it starts
connecting phase. It marks the current state as
Starting. Later, when connection is being established,
it calls back the base QtcProcess::start() and it
fails on assert. This doesn't happen when starting
not in terminal, as in this case SshDeviceProcess
delegates the start to the aggregated SshRemoteProcess
instead of calling QtcProcess::start().

Disabling the assert for a while, until we de-virtualize
the public interface back again, as from the public
API side it's still a valid assert.

Change-Id: I0d62ec0db778f68fcc5afa4a6f08d54f98d74e4f
Reviewed-by: hjk <hjk@qt.io>
2022-02-17 11:43:04 +00:00
Jarek Kobus
0b08b24682 A gift for Alessandro
Add an info to the start process log about whether it was
started by a call to QtcProcess::runBlocking() or not.
In case it was, specify the event loop mode.

Change-Id: Ie1adf0526b341eedcd0d84505075a942b057ff99
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2022-02-17 08:46:56 +00:00
Jarek Kobus
e0d6568751 QtcProcess: Fix a lacking call to setBelowNormalPriority()
Amends 825c89987c

Change-Id: Ib6a812efb924f8ea840b510656fee3a5b3b41fbc
Reviewed-by: hjk <hjk@qt.io>
2022-02-17 08:11:36 +00:00
Leena Miettinen
2a1ce51ce3 Utils: Fix UI text punctuation and capitalization
Also simplify the wording of a message.

Task-number: QTCREATORBUG-27055
Change-Id: I29df31f8484d451d8d8d1869ca3a1b182072d2c1
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-02-16 16:57:17 +00:00
Jarek Kobus
86017efdd4 QtcProcess: Recreate process interface on every start
Since the input data may have changed in meantime.
Ensure we are not running when restarting the process.

Change-Id: I79a515b3c0526a6315027433fd821698fb2c6e94
Reviewed-by: hjk <hjk@qt.io>
2022-02-16 09:55:56 +00:00
Jarek Kobus
82c2450fbe Reuse ProcessSetupData in CallerHandle
Change-Id: I4a2d3fef15331343e7763149550280b722fc3781
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-02-16 09:30:01 +00:00
Jarek Kobus
aa3166df78 ProcessInterface: Simplify start() API
Get rid of program and arguments parameters from
start() method. Get rid of customStart() and isCustomStart()
methods. Provide a default implementation for start() method.
Introduce virtual doDefaultStart() method, to be called when
default implementation for start() is used() - it's being
triggered by a call to defaultStart(). When some implemetation
provides the custom implemetation of start() method
(e.g. TerminalImpl), the doDefaultStart() may stay unimplemented
(won't be called).

Rename WrongFileNameFailure to WrongCommandFailure, as that's
being used also in case when command arguments parsing failed.

Cleanup some unimplemented or unused fields of ProcessLauncherImpl.

Change-Id: I87661e9838dc30888034b2fa62d47c861bf8f9dd
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-02-16 09:20:08 +00:00
Jarek Kobus
d06449d1a5 ProcessInterface: Remove setEnvironment()
Use environment from ProcessSetupData instead.

Change-Id: I8f0436b8ce024ca5ce39ae2cd842b4d195f2c54d
Reviewed-by: hjk <hjk@qt.io>
2022-02-16 09:14:30 +00:00
Jarek Kobus
d520d457c1 ProcessInterface: Simplify customStart() method
Change-Id: I8940ca016076e42a73774a18a24b6b5ce2cb81ad
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-02-16 09:09:31 +00:00
Jarek Kobus
5c3a08bc4b ProcessInterface: Simplify start() method
Don't pass writeData, as that's available through
ProcessSetupData.

Change-Id: Ic55b21c6a3338168ee251bcc1c57594f50c52d2f
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-02-16 09:09:24 +00:00
Jarek Kobus
c49ce24a92 ProcessInterface: Make a copy of ProcessSetupData
Don't share the same instance of data with the QtcProcess
itself, as some of the fields needs to be modified just
for the starting purposes. In this way we avoid cyclic
modifications of the original data on subsequent runs.

Change-Id: I937978ee92f848d247025939ac5b0c6c60c29ff7
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-02-16 08:22:23 +00:00
Jarek Kobus
ccb42b3c74 ProcessInterface: Remove setWorkingDirectory()
It's a part of passed ProcessSetupData.

Change-Id: I125d31cb1b316c1802d1d9d7fb5e1c5b3a3b8c18
Reviewed-by: hjk <hjk@qt.io>
2022-02-15 14:55:46 +00:00
Jarek Kobus
5c1dc2fd5e Move more internal data into ProcessSetupData
It's going to be reused in other parts of implementation.

Change-Id: I4721bba28537d3f00c20c0f3c8e5ca633dc8727e
Reviewed-by: hjk <hjk@qt.io>
2022-02-15 14:54:42 +00:00
Jarek Kobus
ce40605934 ProcessInterface: Remove program() method
It looks it's really unneeded.

Change-Id: Ie9447abfbe57968e5f5302be6b23cb950c4d0ea7
Reviewed-by: hjk <hjk@qt.io>
2022-02-14 16:24:56 +00:00
Jarek Kobus
a3ff220f5b Drop ::ExitStatus:: and ::ProcessError::
That's superfluous. Fix comparison of QProcess::exitCode
with QProcess::ExitStatus.

Change-Id: I49d746fdbbc279e3e04c4ed57d386560e7cbe4b4
Reviewed-by: hjk <hjk@qt.io>
2022-02-14 15:19:44 +00:00
Jarek Kobus
6f1285f508 ProcessInterface: Use Environment and FilePath
Use Utils::Environment for of environment.
Use Utils::FilePath for workingDirectory.

Change-Id: I6b717139f8ff7ddbd629fb22cf816b2303fb5e6a
Reviewed-by: hjk <hjk@qt.io>
2022-02-14 15:16:30 +00:00
hjk
95c9579c58 ProjectExplorer: Normalize DeviceProcess::start() signature
Change-Id: I2915be34d4a1eed64567874dcf0263b7583cc142
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-02-14 15:10:12 +00:00
Jarek Kobus
fd36b4a501 Make ProcessInterface public
It's going to be subclassed in LinuxDevice.

Change-Id: I6308d7cf75a7e16cd02de585612000a1b983fadc
Reviewed-by: hjk <hjk@qt.io>
2022-02-14 10:57:27 +00:00
hjk
f555285aa5 Utils: Fix compilation on Windows
Amends 825c89987c.

Change-Id: I1ec04bcc8b67870bdc26dccb4e67052a32c7ef94
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-02-14 05:44:24 +00:00
hjk
e2cb64471a Utils: Move QtcProcess constructor setup data to shared setup data
This includes replacing DeviceProcess terminal handling with base
member.

Change-Id: Id1541bfce33c71dddc71b4816ad0b174dce3879c
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-02-11 17:33:48 +00:00
hjk
825c89987c QtcProcess: Delay calls to newProcessInstance()
I'd really like to keep/re-enable at least the terminal use
as kind of property not directly tied to the QtcProcess object
life time.

This here is a first step towards this goal (and only a sketch)

I am not sure whether I like using a pointer to a "parent"
data struct as a means to propagate data, but it works, and
it's easy to add a new data item without touching all lower levels.

Change-Id: Ice2d3246951438a14383b097f307fd61306c29db
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-02-11 16:11:43 +00:00
Jarek Kobus
f5b946abbe LinuxDevice: Implement runProcess()
Change-Id: I5300d36119ffb9fdd82a2ba7e02f76edc0fe2eda
Reviewed-by: hjk <hjk@qt.io>
2022-02-03 14:20:18 +00:00
Jarek Kobus
239688180d Fix running as root
There is no need for TerminalRunner::setRunAsRoot()
as debugger is already being run as root.
Implement runAsRoot for non-terminal QtcProcess, too.

Fixes: QTCREATORBUG-26964
Change-Id: Id5110db86b7b809a5608714464241cee73875f2b
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-02-03 10:23:25 +00:00
hjk
3769169b8e Utils: Introduce a struct for QtcProcess ctor arguments
We'll need a lot of combinations.

Change-Id: Ic92ad6fba1d96c42571be76f7c24b253f210b132
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-01-28 12:20:35 +00:00
Jarek Kobus
1d15a934cd QtcProcess: Get rid of useTerminal
Remove SshRemoteProcessRunner::runInTerminal() method,
it wasn't used anywhere (just in test).
Remove QtcProcess::useTerminal, as process should be
created in TerminalOn mode when there is a need for terminal.
Add a parameter to
SshRemoteProcess::fullLocalCommandLine(bool inTerminal)
as this may still be needed when running application
through ssh from terminal (ssh -tt option).

Change-Id: I71911082fcca190b82a1106a2ca1ca48dc5d4c79
Reviewed-by: hjk <hjk@qt.io>
(cherry picked from commit 95a9b22f6f)
2022-01-28 12:19:12 +00:00
Christian Kandeler
6993bc7382 Fix various warnings
Change-Id: Iea85f4b890ce7700e8b3632de4656cf848729a36
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-01-27 10:42:23 +00:00
Jarek Kobus
a09630d50e TerminalRunner: Use QtcProcess in terminal mode instead of ConsoleProcess
Change-Id: I5ddc521ed62947a6bd09eb048408fc9573069615
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-01-25 14:56:28 +00:00
Jarek Kobus
5127d155d2 QtcProcess: Get rid of setProcessUserEventWhileRunning()
Introduce EventLoopMode enum and pass it to the
QtcProcess::runBlocking() instead. There is no need to
store this setting. By default this value is NoEventLoop.

Change-Id: Icad98b77bec5280b79039b7e5aa4ec408261521c
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-01-25 08:44:11 +00:00
Jarek Kobus
8260074c67 Integrate ConsoleProcess into QtcProcess
Change-Id: I8e2b43ef27af6ff279b575a8d43f1ff918562951
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-01-25 08:36:09 +00:00
Jarek Kobus
d6f56254d1 Get rid of QtcProcess::workingDirectory() overload
Adapt all callers' code so that it passes the FilePath
instead of QString. As a consequence introduce
TemporaryDirectory::masterDirectoryFilePath() and use
it where easily possible.

Change-Id: I14564949b3b916921e32a2957c84c03d1da43af2
Reviewed-by: hjk <hjk@qt.io>
2022-01-18 17:18:34 +00:00
Eike Ziller
7d92375b2f Merge remote-tracking branch 'origin/6.0'
Conflicts:
	cmake/QtCreatorIDEBranding.cmake
	qbs/modules/qtc/qtc.qbs
	qtcreator_ide_branding.pri
	src/plugins/clangcodemodel/clangdclient.cpp

Change-Id: I75c954d2e573d65089205d2542747bba3276be2a
2022-01-03 14:14:12 +01:00
Jarek Kobus
f25300cadf Fix a possible crash in process launcher
It may apparently happen that when calling QProcess::start()
we may receive a synchronous signal QProcess::errorOccurred()
from the process we are trying to start. In this case
the handler of the error signal might have removed the
process from m_processes hash, which invalidated the
"Process *& process" reference inside
LauncherSocketHandler::handleStartPacket(). So, using
process reference after calling start() may be dangerous.

Refactor ProcessStartHandler so that it stores the pointer
to the process it handles. The pointer to the handler
should still be valid after calling start(), since
the process itself is being deleted with a delay.

Make ProcessStartHandler a member of ProcessHelper. In this
way it's being reused in QProcessImpl and ProcessLauncher.

Fixes: QTCREATORBUG-26726
Change-Id: I8e3f39953035d76c83bbbb13bd78e3042ba2a14e
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2021-12-21 12:47:05 +00:00
hjk
8cb5c3cfdd Ssh: Use base QtcProcess' useTerminal for SshRemoteProcess
Still trying to ramp down non-QtcProcess interfaces.

Change-Id: I6b4ae6788f5021959ff3eb35bbade2157a6d67fa
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2021-12-06 15:30:00 +00:00
hjk
e64ce914f9 Utils/Ssh: Move SshRemoteProces::isRunning() to QtcProcess base
... and use it on a few places.

Change-Id: Id2cea709e355a46821a720e593740ac032888ced
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2021-12-06 13:44:23 +00:00
Jarek Kobus
15edfc85cb Remove unused m_exitStatus member
Change-Id: Ice572b27964b4c9a3977091caa3224585bc08879
Reviewed-by: hjk <hjk@qt.io>
2021-11-10 12:47:41 +00:00
Jarek Kobus
0556eec9b7 Use a new enum indicating various start failures
Before the m_startFailure flag was used to detect the case
when the process failed to start because of wrong filename.
As this flag was set on any possible error we have always
detected the wrong filename case. Replace this flag with a
new enum describing various start failures.

Don't report again the crashed message. Check if we have already
reported the stop and we don't report it again. The
processExited() handler is being called twice: directly from
localGuiProcessError() and through the delayed localProcessDone().

Fixes: QTCREATORBUG-26467
Change-Id: I3cc6aa0c0b702256cefd77ba95793cd31e82ae10
Reviewed-by: hjk <hjk@qt.io>
2021-10-27 07:53:53 +00:00
Jarek Kobus
4b6b9f4dec Don't instantiate QTimer and QEventLoop for every QtcProcess
These two objects are only used when QtcProcess::runBlocking()
with m_processUserEvents option set is called, otherwise
they are unused. Create them only when they are needed.

This also solves the issue that these two QObjects were not
moved together with QtcProcess when it was moved to another
thread.

Change-Id: I7de6a92a51fc249184fc5811dac7a7bbf05d351f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2021-10-27 06:43:01 +00:00
Alessandro Portale
2fc0ce4843 Utils: Introduce QtcProcess::toStandaloneCommandLine()
The goal is to make a QtcProcess incl. environment, working directory,
executable and arguments testable, e.g. in a terminal. The new
toStandaloneCommandLine() returns a string containing the command line
for a call of "env" the data of the QtcProcess instance as parameters.

To be used like:
  qDebug().noquote() << qtcProc.toStandaloneCommandLine();

..and the debug output can be pasted into a terminal.

Change-Id: Ib6cbea290e1eff3279d6e0a67076a624312af879
Reviewed-by: hjk <hjk@qt.io>
2021-09-10 11:49:07 +00:00
hjk
bdefc13eba Utils: Rename FilePath::absolutePath(FilePath) to resolvePath
There was already a similar function taking a QString.

After that, the remaining no-argument version of absolutePath()
can be deprecated.

Change-Id: I5b9ad8c8b68a5723891b0aa9f5a37e90db0fe09e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-09 05:42:30 +00:00
hjk
152fdd35f5 Utils: Add runAsRoot and useTerminal flags for QtcProcess
Not implemented right now.

Change-Id: Ifdd5870b757f260c72fccb423140584688aa9898
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2021-09-08 14:12:34 +00:00
Jarek Kobus
ace765c199 Move ProcessReaper into lib/utils
Reuse ProcessReaper inside process launcher.
Automatically reap all internal QProcesses of QtcProcess
(either direct child of QtcProcess in QProcessImpl
or indirectly inside process launcher).
Make ProcessReaper work again on QProcess instead of on
QtcProcess, so it may still be reused for non-QtcProcesses.

Change-Id: I950cac5cec28f17ae97fe474d6a4e48c01d6aaa2
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2021-09-06 21:28:19 +00:00
Jarek Kobus
f7aa963a07 Make all objects created by QtcProcess children of it
Sometimes after creating QtcProcess we move it into a different
thread. In this case we should move all the children, too.
Without parent-child relation all the children will stay in the
old thread.

Change-Id: Ibde44d6153092a155dd2d200a7116a046910dddc
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-09-03 10:56:26 +00:00
Jarek Kobus
a454b3dc23 Use QProcess' / process lanuncher's exit code
Change-Id: I802116c45847daf9a647771ee293aef8463fc3c7
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-09-03 10:56:19 +00:00
Christian Kandeler
3be9f52980 Fix some warnings
Unused functions & variables, initialization order, signedness, non-
virtual destructor.

Change-Id: I405d768fe0e02a36a16c2cead9e1bc2f6a23fb75
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-09-02 13:47:07 +00:00
The Qt Project
3c4e7321bf Merge "Merge remote-tracking branch 'origin/5.0'" 2021-09-01 10:56:08 +00:00
Jarek Kobus
1acda50e7f Compile fix
Amends cc940d52be

Change-Id: I8e498a43b3e081415e449d1347398fb01433882d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-09-01 08:42:07 +00:00
Eike Ziller
47de984972 Merge remote-tracking branch 'origin/5.0'
Change-Id: I712fce3cc0171327de122a1cd53b5bae67541084
2021-09-01 10:10:33 +02:00