Locator: Cancel running search when closing

When closing e.g. a separate window with a locator search running, we
don't need the search to continue. Save resources by cancelling it.

Change-Id: I889b9cd163a9cc79045fb0eda9797856c489bd39
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
Eike Ziller
2021-02-11 10:22:25 +01:00
parent 359fa8e877
commit 95e7bdfdb7
2 changed files with 8 additions and 0 deletions

View File

@@ -623,6 +623,13 @@ LocatorWidget::LocatorWidget(Locator *locator) :
updateFilterList();
}
LocatorWidget::~LocatorWidget()
{
// no need to completely finish a running search, cancel it
if (m_entriesWatcher->future().isRunning())
m_entriesWatcher->future().cancel();
}
void LocatorWidget::updatePlaceholderText(Command *command)
{
QTC_ASSERT(command, return);

View File

@@ -57,6 +57,7 @@ class LocatorWidget
public:
explicit LocatorWidget(Locator *locator);
~LocatorWidget() override;
void showText(const QString &text, int selectionStart = -1, int selectionLength = 0);
QString currentText() const;