diff --git a/src/autotype/AutoType.cpp b/src/autotype/AutoType.cpp index cfa030308..67ed5021b 100644 --- a/src/autotype/AutoType.cpp +++ b/src/autotype/AutoType.cpp @@ -433,38 +433,33 @@ void AutoType::startGlobalAutoType(const QString& search) */ void AutoType::performGlobalAutoType(const QList>& dbList, const QString& search) { - if (!m_plugin) { - return; - } - - if (!m_inGlobalAutoTypeDialog.tryLock()) { - return; - } - - if (m_windowTitleForGlobal.isEmpty()) { - m_inGlobalAutoTypeDialog.unlock(); + if (!m_plugin || !m_inGlobalAutoTypeDialog.tryLock()) { return; } QList matchList; - bool hideExpired = config()->get(Config::AutoTypeHideExpiredEntry).toBool(); + // Generate entry/sequence match list if there is a valid window title + if (!m_windowTitleForGlobal.isEmpty()) { + bool hideExpired = config()->get(Config::AutoTypeHideExpiredEntry).toBool(); + for (const auto& db : dbList) { + const QList dbEntries = db->rootGroup()->entriesRecursive(); + for (auto entry : dbEntries) { + auto group = entry->group(); + if (!group || !group->resolveAutoTypeEnabled() || !entry->autoTypeEnabled()) { + continue; + } - for (const auto& db : dbList) { - const QList dbEntries = db->rootGroup()->entriesRecursive(); - for (auto entry : dbEntries) { - auto group = entry->group(); - if (!group || !group->resolveAutoTypeEnabled() || !entry->autoTypeEnabled()) { - continue; - } - - if (hideExpired && entry->isExpired()) { - continue; - } - auto sequences = entry->autoTypeSequences(m_windowTitleForGlobal).toSet(); - for (const auto& sequence : sequences) { - matchList << AutoTypeMatch(entry, sequence); + if (hideExpired && entry->isExpired()) { + continue; + } + const QSet sequences = Tools::asSet(entry->autoTypeSequences(m_windowTitleForGlobal)); + for (const auto& sequence : sequences) { + matchList << AutoTypeMatch(entry, sequence); + } } } + } else { + qWarning() << "Auto-Type: Window title was empty from the operating system"; } // Show the selection dialog if we always ask, have multiple matches, or no matches diff --git a/src/core/Tools.h b/src/core/Tools.h index 168eeca61..3f8fd7c1e 100644 --- a/src/core/Tools.h +++ b/src/core/Tools.h @@ -47,6 +47,15 @@ namespace Tools QProcessEnvironment environment = QProcessEnvironment::systemEnvironment()); QString cleanFilename(QString filename); + template QSet asSet(const QList& a) + { +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + return QSet(a.begin(), a.end()); +#else + return QSet::fromList(a); +#endif + } + /** * Escapes all characters in regex such that they do not receive any special treatment when used * in a regular expression. Essentially, this function escapes any characters not in a-zA-Z0-9.