Always reset Auto-Type state on finished signal

There were a couple code paths that did not reset the state appropriately and could cause undefined behavior in the auto-type processing.
This commit is contained in:
Jonathan White 2024-12-27 17:10:17 -05:00
parent 2ea656bc27
commit 41b6247178
2 changed files with 2 additions and 6 deletions

View File

@ -153,6 +153,7 @@ AutoType::AutoType(QObject* parent, bool test)
#endif #endif
} }
connect(this, SIGNAL(autotypeFinished()), SLOT(resetAutoTypeState()));
connect(qApp, SIGNAL(aboutToQuit()), SLOT(unloadPlugin())); connect(qApp, SIGNAL(aboutToQuit()), SLOT(unloadPlugin()));
} }
@ -353,7 +354,6 @@ void AutoType::executeAutoTypeActions(const Entry* entry,
} }
} }
resetAutoTypeState();
m_inAutoType.unlock(); m_inAutoType.unlock();
emit autotypeFinished(); emit autotypeFinished();
} }
@ -488,11 +488,9 @@ void AutoType::performGlobalAutoType(const QList<QSharedPointer<Database>>& dbLi
m_windowForGlobal, m_windowForGlobal,
virtualMode ? AutoTypeExecutor::Mode::VIRTUAL virtualMode ? AutoTypeExecutor::Mode::VIRTUAL
: AutoTypeExecutor::Mode::NORMAL); : AutoTypeExecutor::Mode::NORMAL);
resetAutoTypeState();
}); });
connect(selectDialog, &QDialog::rejected, this, [this] { connect(selectDialog, &QDialog::rejected, this, [this] {
restoreWindowState(); restoreWindowState();
resetAutoTypeState();
emit autotypeFinished(); emit autotypeFinished();
}); });
@ -506,10 +504,8 @@ void AutoType::performGlobalAutoType(const QList<QSharedPointer<Database>>& dbLi
} else if (!matchList.isEmpty()) { } else if (!matchList.isEmpty()) {
// Only one match and not asking, do it! // Only one match and not asking, do it!
executeAutoTypeActions(matchList.first().first, matchList.first().second, m_windowForGlobal); executeAutoTypeActions(matchList.first().first, matchList.first().second, m_windowForGlobal);
resetAutoTypeState();
} else { } else {
// We should never get here // We should never get here
resetAutoTypeState();
emit autotypeFinished(); emit autotypeFinished();
} }
} }

View File

@ -66,6 +66,7 @@ signals:
private slots: private slots:
void startGlobalAutoType(const QString& search); void startGlobalAutoType(const QString& search);
void unloadPlugin(); void unloadPlugin();
void resetAutoTypeState();
private: private:
enum WindowState enum WindowState
@ -83,7 +84,6 @@ private:
WId window = 0, WId window = 0,
AutoTypeExecutor::Mode mode = AutoTypeExecutor::Mode::NORMAL); AutoTypeExecutor::Mode mode = AutoTypeExecutor::Mode::NORMAL);
void restoreWindowState(); void restoreWindowState();
void resetAutoTypeState();
static QList<QSharedPointer<AutoTypeAction>> static QList<QSharedPointer<AutoTypeAction>>
parseSequence(const QString& entrySequence, const Entry* entry, QString& error, bool syntaxOnly = false); parseSequence(const QString& entrySequence, const Entry* entry, QString& error, bool syntaxOnly = false);