Commit Graph

37 Commits

Author SHA1 Message Date
Andre Hartmann
3fa6861e98 ShellCommand: Some style improvements
Change-Id: Ib9c8a7cd9f207b5f2fad9660183703f83d825575
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2020-06-07 12:43:43 +00:00
Orgad Shaneh
b519c8bc92 Utils: Fix display of first argument
Broke in 00b692e67e.

Change-Id: I65fae0f439a49ccce136626c7c88acd9c9c1693b
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-10-10 15:14:55 +00:00
hjk
251287f0d3 Avoid warning on empty expressions
For some reason, Q_UNUSED includes already a semicolon, adding one
on the user side creates an additional empty statement.

Change-Id: I9c5e8fac381345a60792cb75e2938fd53958d3b0
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-07-23 11:55:59 +00:00
hjk
00b692e67e Utils: Use CommandLine in ShellCommand
... and adapt users.

Change-Id: I218523ffe34720d5fe199aa0ca6892a8dc2985fc
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2019-06-11 11:01:16 +00:00
hjk
ca4ba34229 Use Utils::FilePath in SynchronousProcess
Adapt callers and surrounding code.

Change-Id: Ie6c1883a44169cf9d790d06b660f46d24dc24c89
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-06-11 08:11:07 +00:00
hjk
473a741c9f Utils: Rename FileName to FilePath
More in line with QFileInfo terminonlogy which appears to be
best-of-breed within Qt.

Change-Id: I1d051ff1c8363ebd4ee56376451df45216c4c9ab
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-05-28 12:23:26 +00:00
Alessandro Portale
616e19ff9e Fix warning: "Missing emit keyword on signal call"
[-Wclazy-incorrect-emit]

Change-Id: I93bdc6e23cdaccf35c9899ae16870ccc65a54f80
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2019-01-17 15:54:56 +00:00
Orgad Shaneh
2f41f35952 Git: Make commit a bit less synchronous
If gc.auto is configured, commit can trigger garbage collection, which
takes time. Avoid completely blocking the UI on this case, and at least
show the output of the commit command.

Change-Id: Id301c878c26599bbc363928a6770c04369a62f2f
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2018-11-14 13:37:49 +00:00
Alessandro Portale
f6943a712a Utils: Modernize further
Many issues, mostly in headers, were not addressed in
e38410b76c

modernize-use-auto
modernize-use-nullptr
modernize-use-override
modernize-use-using
modernize-use-default-member-init
modernize-use-equals-default

Change-Id: I320a51726db881e582b898948d53735ebb06887a
Reviewed-by: hjk <hjk@qt.io>
2018-07-24 12:21:42 +00:00
Alessandro Portale
e38410b76c Utils: Modernize
modernize-use-auto
modernize-use-nullptr
modernize-use-override
modernize-use-using
modernize-use-default-member-init
modernize-use-equals-default

Change-Id: I8d44d9405011a1878353baf9325f7af90b89db02
Reviewed-by: hjk <hjk@qt.io>
2018-07-20 13:36:22 +00:00
Orgad Shaneh
7cee991c70 Utils: Remove superfluous qualifications
Change-Id: I36e17dac0cff87f82f0ddaf97bc613389110f218
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2018-07-19 08:21:29 +00:00
Orgad Shaneh
b82ffb917b VcsCommand: Block auto reload while a command is running
Git rebase is executed in the background, and it can change a file multiple
times in a short period. If we reparse a file while this happens on
Windows, Git fails to replace it, the rebase action fails and the
repository becomes unstable (remains with a modified file).

See discussion at https://github.com/git-for-windows/git/pull/1666

Task-number: QTCREATORBUG-15449
Change-Id: Iba40a770a1df2dfff0dd1c874c491dfbe1cceb58
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2018-06-27 09:43:47 +00:00
Orgad Shaneh
e20aa431ed ShellCommand: Apply progress parser also to stderr
It is only used for Rebasing message in Git, which was moved from
stdout to stderr on Git 2.12.

Change-Id: I761cb7ac4e0d19fc28b323076dd3b0919535ed32
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-10-04 07:50:34 +00:00
Eike Ziller
c4b5048836 ShellCommand: Show some progress information without progress parser
Show magically timed progress when running a shell command without a
progress parser. The assumption is that the timeout is much larger than
the expected runtime, but still an indicator for how long it might take.
Progress manager does its magic on top of that.

This is e.g. used for the update info plugin, for which checking for
updates might take quite some while.

Change-Id: Ib3d3d37b86fac17816fe592e39e26a3d484bba26
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-09-07 11:24:33 +00:00
Tobias Hunger
ad2b968e4c ShellCommand: Fix crash with OutputProxy use
Pass a shared pointer into runSynchronous and runFullySynchronous.
That way the proxy will stay around for as long as needed.

Task-number: QTCREATORBUG-16612
Change-Id: Ic529440c81d85149abd67e5eeb564cc5f12181ab
Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
2016-07-18 12:06:12 +00:00
Tobias Hunger
b851b57ea3 Utils::ShellCommand: Force fully synchronous execution from UI thread
Force runCommand when run from the UI thread to do fully synchronous
operations. This prevents two event loops in one thread with (sometimes)
interesting side effects.

This also stops signals from being sent while the process is running,
but the remaining users seem to be able to handle that.

Change-Id: Id5eb9868b660419987730c60e3fbfb4cbced1218
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2016-07-15 14:49:02 +00:00
Tobias Hunger
2c5095c94d Utils::ShellCommand: Use SynchronousProcess where posssible
Use SynchronousProcess::run and SynchronousProcess::runBlocking.

Using SynchronousProcess::run in ShellCommand::runSynchronous
is generally safe, since this method is usually called in its
own thread. This makes the processing of cancel requests work
again and makes output available via signals.

Task-number: QTCREATORBUG-16532
Change-Id: I6907194bd00cd5713673d9b1911978d69b996a80
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2016-07-15 14:24:05 +00:00
Tobias Hunger
d1be129abe Utils::ShellCommand: Add runSynchronous method
Add runSynchronous method and move code from runCommand there.

Change-Id: Ic7c452d583fd88468fc6466a683159ecd8328b48
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2016-07-15 14:22:39 +00:00
Tobias Hunger
c2075f6a73 ShellCommand: Pass OutputProxy to runFullySynchronous
No need to create a fresh one.

Change-Id: I3c7b92319ab43030620428987dfa254be7ac03a7
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2016-07-15 14:22:02 +00:00
Tobias Hunger
53c602633c Utils::ShellCommand: Rename runSynchronous to runFullySynchronous
This name just got free, so use it for the method that actually is
called if the process runs with the FullySynchronously flag set.

Change-Id: Ic86bb291d578ad06b74db1ab89a22b1b8cb4f4bb
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2016-07-15 14:21:40 +00:00
Tobias Hunger
cc27125092 Utils::Shellcommand: Remove runFullySynchronous
Nobody uses that anymore.

Change-Id: I24935ac8d25eb639eb253250749750993c740516
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2016-07-15 14:21:21 +00:00
Tobias Hunger
5efd82468b SynchronousProcess: Store raw bytes from stdout/stderr of the process
Only convert the raw output later in a stdOut() and stdErr() method of
the SynchronousProcessResponse.

This is necessary since we have processes that use different encodings
for different sections of the file (I am looking at you, git).

Also remove the signals for raw data on stdout/stderr, leaving only the
signals returning buffered QString lines. This should be safe, even
with UTF-16 output.

Change-Id: Ida613fa86d1468cbd33bc6b3a1506a849c2d1c0a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2016-07-15 14:16:03 +00:00
Tobias Hunger
d5dc6f7f70 Utils: Use runBlocking in shellcommand
This is run in a background thread, so there is no need to keep the UI
alive.

Change-Id: I81267b918ef2350a180b0a8ee55244feca2406b4
Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
2016-06-24 08:14:32 +00:00
Orgad Shaneh
05966ab153 Utils: Suppress progress bar when "Suppress command logging" is enabled
Change-Id: I6c94352f0c816920c4b97801da050bf14ea7be66
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2016-05-09 07:40:14 +00:00
Eike Ziller
967177d3d8 SynchronousProcess: Change exit code interpreter to function object
Change-Id: Ic48d4f5810f171c070f0980581fb6e45f6fe6b4a
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2016-04-27 08:48:32 +00:00
Orgad Shaneh
f07a309129 Utils: Modernize ShellCommand and SynchronousProcess
* Reorder members to avoid padding
* Use C++11 member initialization

Change-Id: Ib04c2d59dfcf54f5df7afddc6e21197f1095e829
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
2016-04-01 08:35:25 +00:00
Eike Ziller
dd7915acfe ShellCommand: Add missing include
It was included only by another included header.

Change-Id: Idff745a7d811c7fe0c4c791eeda884bcd4a62d98
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2016-02-12 13:43:28 +00:00
Eike Ziller
72af6b7834 runAsync: Remove ResultType template parameter.
It is now deduced from either the type of the
QFutureInterface<ResultType> function argument, or the return type.

Change-Id: Iddab3cc329206c649a6e55a44b2de2d406701dee
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
2016-02-10 10:58:55 +00:00
Orgad Shaneh
9a723a0c98 Utils: Fix indentation in ShellCommand
Change-Id: Ia93d5f50c4ea1e130ddfafe763fe0bd5cc95fad1
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
2016-02-05 11:55:39 +00:00
Eike Ziller
40fd545bf6 ShellCommand: Cleanup includes
Change-Id: I87ccf8bed5a09bcd0f8572aa3999fbbf1a1db2b4
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2016-01-30 16:54:35 +00:00
Eike Ziller
4659f2caca ShellCommand: Some tweaks of QtConcurrent usage
Use Utils::runAsync to avoid use of global thread pool. Move watcher
connect to constructor. Report "failure" of the command by internally
canceling.

Change-Id: Ib7616734176be2ad9356162724ca06cfd8821e52
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
2016-01-26 10:27:09 +00:00
Tobias Hunger
f72370f20a Update License according to agreement with Free Qt Foundation
* Update remaining files in src

Change-Id: I1896f17fcf34f71c3310c87899fb5171b8e4afb1
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
2016-01-19 15:59:41 +00:00
Tobias Hunger
3652ca52bc ShellCommand: Do not crash when no binary is given
Task-number: QTCREATORBUG-14643
Change-Id: I9c62904c271e2c2a94785dd8223b60d588da822b
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
2015-06-30 14:58:02 +00:00
Tobias Hunger
f2be797696 ShellCommand: Allow setting working directory per job
Change-Id: I6d541f87b76bdc7f1503f202792079f833e8932c
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2015-06-10 13:04:42 +00:00
Tobias Hunger
ea476ffc39 ShellCommand: Store workingdirectory in the jobs
Not all jobs of one command can run in the same directory, so
prepare for having individual working directories per job.

Change-Id: Ice43361fe54f2b7153ccd38435f6108d83570082
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2015-06-10 12:05:31 +00:00
Tobias Hunger
a44c403b5f ShellCommand: Rename some signals
Rename the signals used to report stdout/stderr to make it clearer
what they actually do. Remove some unimplemented private member
functions while at it.

Change-Id: I7e856f906ccb45964f3b1b64336d4d8ebca7b9ee
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2015-05-07 13:07:14 +00:00
Tobias Hunger
eec0a03212 Vcs: Split up VcsCommand
Move the biggest chunk into Utils::ShellCommand, add some Qt Creator
specific magic in Core::ShellCommand and leave the rest in
VcsBase::VcsCommand.

Change-Id: I5fe6f7076e96023ad2164bcfaacfb3b65a7ff8a8
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2015-05-04 15:27:25 +00:00