diff options
author | Thomas Hartmann <thomas.hartmann@qt.io> | 2022-02-18 13:44:12 +0100 |
---|---|---|
committer | Thomas Hartmann <thomas.hartmann@qt.io> | 2022-02-18 15:06:44 +0000 |
commit | 4cbe956722af219be73b6720ad8c804b4cfebd82 (patch) | |
tree | 1bcfca1b4014e31a9d91c57533b1a8aaa6c35c58 /src | |
parent | a29154225e922222384f691fee48196d18f2195c (diff) | |
download | qt-creator-4cbe956722af219be73b6720ad8c804b4cfebd82.tar.gz |
QmlDesigner: Cache result of eventListEnabled
Calling EventList::hasEventListModel() takes time, since it includes
file access. Since eventListEnabled() is called on each selection change,
we cache the result. If the root node is the same, also the document is the
same and there is no reason to check again.
This way we check only once per document.
Change-Id: Id664811b1319a306c70283d2b37de258a129892f
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Knud Dollereder <knud.dollereder@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/qmldesigner/components/eventlist/eventlistactions.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/plugins/qmldesigner/components/eventlist/eventlistactions.cpp b/src/plugins/qmldesigner/components/eventlist/eventlistactions.cpp index 823ce30da3..a23b8f83a2 100644 --- a/src/plugins/qmldesigner/components/eventlist/eventlistactions.cpp +++ b/src/plugins/qmldesigner/components/eventlist/eventlistactions.cpp @@ -33,9 +33,18 @@ namespace QmlDesigner { -inline bool eventListEnabled(const SelectionContext &) +inline bool eventListEnabled(const SelectionContext &context) { - return EventList::hasEventListModel(); + static ModelNode lastRootNode; + static bool lastValue = false; + + if (lastRootNode == context.rootNode()) + return lastValue; + + lastRootNode = context.rootNode(); + lastValue = EventList::hasEventListModel(); + + return lastValue; } QIcon eventListIconFromIconFont(Theme::Icon iconType) |