Commit Graph

2869 Commits

Author SHA1 Message Date
Marcus Tillmanns
3ac5051af9 Utils: Fix FilePath::fromString host decoding
Previously FilePath::fromString did not decode %25 (%) and %2f (/),
so a round of ::fromString(::toString()) would not return the same host.

Change-Id: I99c7317fb149443c2e52c099f7da7c4ef6768aff
Reviewed-by: hjk <hjk@qt.io>
2022-10-20 06:45:42 +00:00
hjk
4266f612e6 Utils: Rename FilePath::relativePath() to relativePathFrom()
Hopefully less confusion about the direction.

Change-Id: I61727d6c4d19e0dfe46f24ff24f5d90f9835d05c
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-10-18 13:41:24 +00:00
Marcus Tillmanns
a22d62e57d Utils: Add FilePath::isSameFile()
FilePath::isSameFile() checks if two files are the same file.
It first checks if its on the same device. If it is, it will
try to read the fileId of the files and compare them.

Change-Id: I83668955cacd4e5ed03d43a3fee2be29e9d0a6f0
Reviewed-by: hjk <hjk@qt.io>
2022-10-13 11:25:48 +00:00
hjk
1fa3255242 Utils: Split off file access interface from IDevice
The file accessing functions form now a class hierarchy by themselves,
the devices return a suitable point.

The previous implementation was mildly confusing by the special handling
of the DesktopDevice, fallbacks and remote cases in the same function
leading to unnecessary boilerplate when adding new functions and
codepaths that sometimes passed the FilePath API twice.

Implemented are a "DesktopDeviceFileAccess" taking care of the
previous !needsDevice() branches and a "UnixDeviceFileAccess"
covering the current docker and RL uses.

As a side-effect this unifies to a large degree the current docker
and RL code paths with were occasionally deviating from each other
while they shouldn't.

Change-Id: I4ff59d4be2a07d13e2ca5e9ace26a84160a87c9d
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-10-13 10:38:35 +00:00
Marcus Tillmanns
271c9055f4 FSEngine: Add filePathInfo devicehook in tests
Change-Id: I50b87e213d8c83fa8d126662655681416c1cbe4e
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-10-12 09:36:14 +00:00
hjk
b1471fe61f Utils: Combine some of the iterateWithFind overloads
Change-Id: I668447d0049f2e35cd0c76d2c5708779196167ec
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2022-10-12 08:59:32 +00:00
Jarek Kobus
c50891611a FilePath: Fix absoluteFilePath to behave like absolutePath
Change-Id: Ibb2cba32c40ec9febab5f20c78156481525c8904
Reviewed-by: hjk <hjk@qt.io>
2022-10-11 14:33:35 +00:00
Jarek Kobus
ecd9053587 tst_qtcprocess: Remove 30 seconds timeout overload
The default is 60.

Change-Id: I22585a62648376c771f6f3e4165dc4a1bef25892
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-10-11 07:34:39 +00:00
hjk
2e38cb6848 Utils: Add an offset parameter to the content writing FilePath function
Use QFile::seek to implement locally and a dd seek based poor man's
implementation on RL and docker.

Change-Id: I241d1c34c00e991845d132ad8edefa1377ba1311
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-10-10 16:08:28 +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
hjk
5dde520a43 Utils: Return a bit more data from DeviceShell::runInShell
Pass on stderr data and exit code to the caller, it's typically
in a better condition to handle errors.

Use it to notify the user about non-available 'find' arguments
and fix the fallback to ls-based operation.

Change-Id: I535535de2ffa09cad1dd6e9b07eb69f807dbae2f
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2022-10-10 08:39:55 +00:00
Eike Ziller
ce9da99528 FilePath: Fix isRelativePath for QRC paths
Implicitly fixing methods like absoluteFilePath too.

Fixes e.g. JSON wizards that are registered from a plugin QRC file, like
McuSupport wizards (run with McuSupport plugin enabled and create a
"Application (Qt for MCU)" application).

Change-Id: I296ba1c5eb63c9eb27f9a55e65019125faf546ea
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-10-10 06:14:44 +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
hjk
23e96dd6fe Utils: Use a single QString as data store for FilePath
Plus a few integers to get access to the pieces.

This reduces sizeof(FilePath) from 72 to 32.

Change-Id: I65eb856ad47b6a250c705d8d01893781a21d8e02
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2022-10-04 07:27:16 +00:00
Jarek Kobus
f65c42c797 Various plugins: Limit the usage of std::make_pair
Make the code less verbose.

Change-Id: I22ceb8d74567d78042f537b185f8e504227c24c6
Reviewed-by: hjk <hjk@qt.io>
2022-09-30 13:37:52 +00:00
Christian Kandeler
7b9fec2aa8 Debugger: Remove CMAKE_INCLUDE_CURRENT_DIR from autotest project file
Not needed.

Change-Id: Ia75cd0b70f2976a03948e7d8569027f6c0242344
Reviewed-by: hjk <hjk@qt.io>
2022-09-26 15:03:44 +00:00
Eike Ziller
4fd4b42f3d Fix FilePath::absoluteFilePath for default constructed file path
FilePath::absoluteFilePath() would consider an empty path to be
relative, and resolved it wrt the current working directory. That is
unexpected in the sense that QFileInfo::absoluteFilePath behaves
differently, and lead to a crash down the line when e.g. a diff editor
was opened when the current working directory is '/' (the default on
macOS when started with "open" or from Finder, Dock or Spotlight).

Make FilePath::absoluteFilePath() return and empty path if the input was
empty.

Change-Id: Ie0d4da50afa24134bd56505b2f4abcf382eee982
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-09-26 07:43:36 +00:00
Marcus Tillmanns
d97b2fd6f4 FSEngine: Add tests for reading/writing
Change-Id: If38d27933727d4af0b24758bdf1a58f5ea78fd1b
Reviewed-by: hjk <hjk@qt.io>
2022-09-23 11:19:35 +00:00
hjk
dd585c601c Utils: Make path cleaning platform agnostic
Unfortunately, QDir::cleanPath() only cleans according to the rules
of the host system, which can be wrong in remote setups.

As the implementation is not accessible/tweakable from the outside,
copy the relevant code and remove the platform #ifdef's.

Change-Id: Ife9a925412a12d3cef21ed3721a387c61c152ddf
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-09-23 09:25:05 +00:00
hjk
815f3e87b8 Utils: Don't create FSEngineImpl::m_tempStorage on close()
It's too late, and apparently "close-without-open" is triggered:

QDEBUG: tst_fsengine::testRootPathContainsFakeDir() SOFT ASSERT: "m_tempStorage" in /data/dev/creator/src/libs/utils/fsengine/fsengine_impl.cpp:64
QDEBUG: tst_fsengine::testListDir() SOFT ASSERT: "m_tempStorage" in /data/dev/creator/src/libs/utils/fsengine/fsengine_impl.cpp:64

Change-Id: Ic7100d7abddfffca909b412ea7ea19e295c86729
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-09-23 05:37:59 +00:00
Marco Bubke
0be4de69d8 QmlDesigner: Remove parent from abstract view
We apply not very often the parent to views. So it can lead to dangling
pointer if the parent is used by other objects and does not handle the
null pointer case. It can lead to double deletion if the parent is
deleted before the object when it is on the stack or handled by smart
pointer.

If you really want to use it there is still setParent.

Change-Id: I1fc6b145a50f037a0e9d415fb36e7970ea7296ed
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2022-09-22 19:08:12 +00:00
Marco Bubke
4bb4e07ad8 QmlDesigner: Inline SynchronizeCommand
Change-Id: Id030fb6aba7f1ba61ce97ebebb5e91a809ab6d8d
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-09-22 19:06:21 +00:00
Marcus Tillmanns
852ded54d0 DeviceShell: Test no-script fallback
Change-Id: I97f6df6face701b247b6be3320d89511a1310857
Reviewed-by: hjk <hjk@qt.io>
2022-09-22 13:36:03 +00:00
hjk
a35a19d165 Utils: Introduce FilePath::{root,schemeAndHost}Length(QStringView)
Intended as helpers for parentDir() to stop when cutting components.

Change-Id: I7615803743351a733d6f3cc9813e9de85973dc61
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2022-09-22 09:19:42 +00:00
David Schulz
85c5edcb6b FuzzyMatcher: add option to match text with spaces
Change-Id: I0480b57d27f3625933005ca2233e9612df53072d
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-09-20 10:31:39 +00:00
Christian Stenger
215b2ce09b Tests: Fix expectation and remove os limitation
Change-Id: I6007c25ec4167083134b0cd03fdff8a9ff34355d
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-09-20 10:12:34 +00:00
hjk
3dff69979b Utils: "Fix" UNC file path parsing
... by adapting the expectations.

Change-Id: If3a3fe2def370440f1edbbcb5a1c2646f1239f67
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-09-19 13:24:43 +00:00
hjk
3522097a8b Utils: Normalize backslashes on FilePath parsing again
Change-Id: I8ee0bc53244785d78acfad406664a907ab088301
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-09-19 13:24:20 +00:00
hjk
b3200b7730 Utils: Move 'isWindowsHost' test to startsWithDriveLetter callers
"Fixes" one Q_SKIP and makes the implementation OS-agnostic.

FilePath::osType() actually depends on the host system for not fully
qualified file paths, and that doesn't seem to be the right thing to do
in all cases. The caller may actually have more context to decide
whether this is needed (e.g. in pathchooser.cpp in the context of
"return value from a GUI element, i.e. 'host' implied).

Change-Id: Iff80c17094d2deec79d34d0527223fbcf8294935
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-09-19 13:14:58 +00:00
Marcus Tillmanns
cc6a7b113a fileutils: Fix tests
Change-Id: Iafeab41b0e6f7cdb10802e48c3bc7fe5548c064c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-09-19 11:01:30 +00:00
The Qt Project
f2c57db69f Merge "Merge remote-tracking branch 'origin/8.0'" 2022-09-19 08:56:50 +00:00
hjk
85c899de63 Utils: Make root recognition in FilePath::fromString host agnostic
Fixes a few XFAILS and a QSKIP

Change-Id: I012d873097dfa0ea565adc4e9a2b34f6c21db9dc
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-09-19 08:51:20 +00:00
Eike Ziller
5d55cfdae5 Merge remote-tracking branch 'origin/8.0'
Conflicts:
	share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ColorEditor.qml
	share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/icons.ttf
	src/libs/utils/fileutils.cpp
	src/plugins/qmldesigner/components/edit3d/edit3dwidget.cpp
	src/plugins/qmldesigner/designercore/include/abstractview.h
	src/plugins/qmldesigner/designercore/include/nodemetainfo.h
	src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp
	src/plugins/qmldesigner/designercore/model/model_p.h
	src/plugins/remotelinux/linuxdevice.cpp
	tests/auto/utils/fileutils/tst_fileutils.cpp

Change-Id: I26a21e2523d3d725fdb8c548a531cdbdaeaeca20
2022-09-19 09:54:06 +02:00
hjk
2f2e266fdf Utils: Make FilePath::toString() output OS-independent again
Change-Id: Ica7c09ea39a38e3425b28c63b6001ad7ad641a4f
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2022-09-19 07:44:26 +00:00
hjk
31556332f5 Utils: Make FilePath::toFSPathString a full copy of toString
Changing the toString() to prepend system-specific prefixes
to cater for the remote filesystem model handling had unintended
sideeffects.

This here is the first step to split both paths.

Change-Id: I66cdd9a87802408e2ba95c2e29b9d7cce7fe2553
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-09-16 08:24:20 +00:00
hjk
2369dcc324 Utils: More cross-platform fileutils/root() tests
Don't hardcode a single type of OS (Windows/Non-Windows) via
QDir::rootPath(), actually check both, independent of the host OS.

Most of the new tests are actually failing, as the parsing code uses
the host OS. Mark those tests as "Expexted fail" for now.

Change-Id: Ic907582ad3959ef95b9618826d987d4eab463b49
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-09-15 14:09:06 +00:00
Eike Ziller
e7ddd8a5b7 FilePath: Return optional bytearray from device hooks
For differentiating between "error" and "empty file".

Change-Id: I1806bb7386f5e7db28489f9f7e685648bfc20110
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-09-15 11:28:18 +00:00
Marcus Tillmanns
b573250a8a FSEngine: Disable tests on Windows
Recent changes in FilePath made it incompatible with windows targets
(by design). Therefore we disable the tests here.

Change-Id: I2182c64f36268f5ab6282d149930653a79cc9aa1
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-09-15 07:44:27 +00:00
Marcus Tillmanns
ed46f1f002 linuxdevice: Fix ::bytesAvailable
DeviceShell does not support piping commands at the moment.

To continue to support ::bytesAvailable the parsing of the
output from "df" is moved to FileUtils::bytesAvailableFromDFOutput.

Change-Id: Ia229208748aa6c572b99899e6ae042bdd5654f4a
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-09-15 05:21:52 +00:00
Marco Bubke
e4b8e78ca2 QmlDesigner: Refactor validation checks
Origanally my idea was that there can be no invalid model nodes created.
Because it was practically to return invalid nodes we added a default
constructor. So now we have invalid nodes because we explicitly created
them and invalid nodes because we destroyed them(except the root node
which has to be always valid). To remove all the isValid test two new
approches are introduced.

Instead of throwing an exception a reasonable return value is provided
or the function is simply doing nothing.
For example if you try to remove an non existing property nothing is
happen. If you try to get an non existing property you get an invalid
property. If you then try to get an value from that property you get an
null(false) value.

All object can now be tested for true or false. So you can write:

if (auto property = getnode().property("foo"))
    // do something with if node and property are positive

Task-number: QDS-7454
Change-Id: I9ebb0bae45354cedc0b6cfe610d1a71435ee1f38
Reviewed-by: Aleksei German <aleksei.german@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-09-14 13:08:31 +00:00
Christian Stenger
a484f3fef5 Tests: Add fsengine related tests to qbs build
Change-Id: I05d6c1da01c972cfcfc15d2d09b57f29e248fad1
Reviewed-by: hjk <hjk@qt.io>
2022-09-14 10:38:19 +00:00
Marco Bubke
40aa1eee06 QmlDesigner: Reactivate coretests
Change-Id: Ia4b6b4b6cd25ad4bb5ff0e0a7c5629af2f5ed6db
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-09-13 14:13:12 +00:00
Marcus Tillmanns
2f0a26c1f5 Filepath: Revert "root"
Change-Id: I3f8e8d8eb32f4e3246942aad2f1205034bfafc07
Reviewed-by: hjk <hjk@qt.io>
2022-09-13 07:58:04 +00:00
Eike Ziller
2456f8f568 Convert file search API to FilePath
Fixes: QTCREATORBUG-28135
Change-Id: Iec8fcbae40adcccbe775de5719a657f5aa30a941
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-09-12 12:24:48 +00:00
Eike Ziller
2c51e4bc17 FilePath: Return optional bytearray for file contents
For differentiating between "error" and "empty file".

Change-Id: I2c019ceac625e7be3180afa4d47ae3a24df91c1d
Reviewed-by: hjk <hjk@qt.io>
2022-09-12 11:57:04 +00:00
hjk
e197acd97b Utils: Make tst_fileutils::fromString() independent of host os
Also, add checks for the resulting root() bits

Change-Id: I3f82b5be95ab89c65d904fc941d537582bd54876
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2022-09-08 11:49:47 +00:00
Marcus Tillmanns
58b8005f03 Process Test: Skip unix only test on windows
Change-Id: Ie019af53a6b41784275d4b64b57a9c3bd493a24c
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-09-06 14:33:36 +00:00
hjk
b94d4f75d0 Utils: Code cosmetics in tst_fileutils.cpp
Change-Id: I2afc6e96f53d8bc2a7c9a8125bdd8ba9b6510baa
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-09-06 10:56:07 +00:00
Jarek Kobus
a9eb732ce6 FileSearchResult: Use FilePath for fileName
This saves about 2 seconds out of 5 seconds spent in
displayResult() for converting from QString into
FilePath in main thread (use case: gitgrep with
2 million hits).

Change-Id: I6334e8559986501c34c90a5c7c6b4acc9a6953e0
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-09-06 07:02:15 +00:00
hjk
56a8c59845 Utils: Make OsType addition less visible
Change-Id: I092930ef6b0ed6876e32ed6b0c78d6bd58becddc
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-09-02 08:25:27 +00:00