Commit Graph

14 Commits

Author SHA1 Message Date
Eike Ziller
e3b639047f Don't update extra compilers individually after project load
Each call of CppModelManager::updateSourceFiles detaches the current
snapshot.
The extra compilers where set up and triggered individually, and
resulted in individual updateSourceFiles calls with the single result
file of the extra compiler. For Qt Creator this would lead to 200
calls in quick succession after project load, potentially leading to a
freeze of multiple seconds.

Instead of updating the result files of the extra compilers individually
after project load, integrate the update into the regular project source
file update. So we end up with only a single call of updateSourceFiles.
For this the project updater needs to trigger the extra compilers, and
wait for all to finish as well as the regular project part update,
before
triggering the parser.

Task-number: QTCREATORBUG-25783
Change-Id: I34f6df0fc0f96bcb42ee65019bee39cf49176c1f
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-07-05 08:16:25 +00:00
Jarek Kobus
03b7324325 CppProjectUpdater: Wait for all tasks to be finished in d'tor
It may happen that the old task was canceled and still running
while the new task was started. Later, when the d'tor is called
both old and new tasks may still be running. Before we waited only
for the new task to be finished in d'tor. Now we are waiting
for all tasks to be finished.

Amends: 7fb592fe0c

Task-number: QTCREATORBUG-25709
Change-Id: Id4b44cd36ee03aa45472b15d8fbb25a2cab77e92
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-05-27 07:56:35 +00:00
David Schulz
7fb592fe0c CppTools: Fix UI freeze on project update
Do not wait for the previous update to finish before starting the next
update.

Amends: 6d7e5eb8d1

Change-Id: Ic8d43b56949cbf024832afc85e54a31db29b11ac
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-05-07 11:28:05 +00:00
Jarek Kobus
2b414508b7 Remove unneeded includes
Change-Id: I67fee9303509b7080e123a2a5826e200ce498ce2
Reviewed-by: hjk <hjk@qt.io>
2020-11-12 12:14:11 +00:00
Eike Ziller
6d7e5eb8d1 Fix CppProjectUpdater cancelAndWaitForFinished
The code was pushing an additional QFutureInterface through the whole
chain of functions, which was used for canceling. But since it was never
started (and never finished, and never used for reporting results),
calling waitForFinshed on it never had any effect with Qt5 and locks up
with Qt6.

Instead of using a separate QFutureInterface, use the actual QFuture
that is available and intended for it.

Fixes: QTCREATORBUG-24902
Change-Id: I5a49bcecc9cf70fbffa93aee4293004f9369df58
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-11-11 12:49:33 +00:00
Jarek Kobus
34c97ac868 Fix a build with Qt 6
In Qt 6 implicit conversion between QFuture and other types
is forbidden. Make it explicit instead.
See ff0ba7e2d7b91fd5809cb314935a1ca1a436f6c9.

Change-Id: Ie42e6b9b5047ba5eeec9f63fd03179e73f95314d
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-11-05 08:46:43 +00:00
Christian Kandeler
cd9571b4f7 CppTools: Optionally move raw project parts creation into thread
... by letting callers pass in a generator function.
This takes some load off the UI thread for larger projects.
For now only used by the QbsProjectManager, which can provide a thread-
safe generator function due to the project data existing in "value"
form.

Task-number: QTCREATORBUG-18533
Change-Id: I525dea36a4c4079bd1bd5a4fff844617547d56f1
Reviewed-by: hjk <hjk@qt.io>
2020-02-06 15:53:46 +00:00
Eike Ziller
b6c2277146 GenericProject: Make dependency on CppTools optional
Especially in the light of the language server, the generic project is
currently the project one can use for language servers that require a
"project workspace".

Makes it possibly to run Qt Creator with
"-noload CppTools" if you still want to use generic
projects with some other language.

Change-Id: Ib9059289a2db4c44c0c1060a02fcdafacb885fbd
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-09-13 06:43:02 +00:00
Eike Ziller
ed9177f74c CppTools: Move ProjectUpdateInfo to ProjectExplorer
Used for updating project parts, so move it near RawProjectPart.

Change-Id: I77aeffbdbfb3d2ec0de600f61dcf7fbb7a355a98
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-09-12 06:37:41 +00:00
Bernhard Beschow
3bdb7d1de5 CppProjectUpdater: Remove unread attribute
Change-Id: I51123e5b5609de431cfa6d1558aed0b9739ff9c8
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-01-06 21:49:28 +00:00
Bernhard Beschow
552e730426 QbsProject: Remove unread attribute
Also remove the signal CppProjectUpdater::projectInfoUpdated() which is
now unused.

Change-Id: I65afe8f96cd8175edaf8ccb6e5067e4f9cd8d99f
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-01-06 21:48:42 +00:00
Bernhard Beschow
763e0d059e CppProjectUpdater: Reuse cancelAndWaitForFinished()
Change-Id: I749dd0244175060ce79d6050b12b729866c06c9d
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2018-12-19 13:27:37 +00:00
Tobias Hunger
3529e785c4 CppTools: Make create* methods return something
Change-Id: I20cfdaef23e9b7c48c9d3b4f27157e771fd9bc7f
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-11-01 14:19:29 +00:00
Nikolai Kosjar
8c90998fff CppTools/ProjectManagers: Reduce ui blocking when loading projects
${AnyProject}::updateCppCodeModel() did two potentially not that cheap
operations in the ui thread:
 (1) Querying the MimeDatabase for the mime type for the source files of
     the project. In 99.9% of the cases no files need to be read for
     this as the file extension will resolve the type. The expensiveness
     comes from the sheer number of files that can occur.
 (2) Calling compilers with the "(sub)project's compiler command line"
     to determine the macros. While the caches avoid redundant calls,
     the number of the unique compiler calls makes this still a
     ui-freezing experience.

These two operations are moved into a worker thread. For this, the
expensive compiler calls are encapsulated in thread safe lambdas
("runners") in order to keep the "mutexed" data minimal. The original
API calls of the toolchains are implemented in terms of the runners.

While adapting the project managers, remove also the calls to
setProjectLanguage(). These are redundant because all of the project
managers already set a proper value in the constructor. Also, currently
there is no need (client) to report back detection of C sources in
project parts. This also keeps CppProjectUpdater simple.

There is still room for improvement:
 * Run the compiler calls in parallel instead of sequence.
 * Ensure that the mime type for a file is determined exactly once.

Change-Id: I2efc4e132ee88e3c8f264012ec8fafe3d86c404f
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-02-20 09:18:13 +00:00