Skip to content

Commit 41b6247

Browse files
committed
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.
1 parent 2ea656b commit 41b6247

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

src/autotype/AutoType.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ AutoType::AutoType(QObject* parent, bool test)
153153
#endif
154154
}
155155

156+
connect(this, SIGNAL(autotypeFinished()), SLOT(resetAutoTypeState()));
156157
connect(qApp, SIGNAL(aboutToQuit()), SLOT(unloadPlugin()));
157158
}
158159

@@ -353,7 +354,6 @@ void AutoType::executeAutoTypeActions(const Entry* entry,
353354
}
354355
}
355356

356-
resetAutoTypeState();
357357
m_inAutoType.unlock();
358358
emit autotypeFinished();
359359
}
@@ -488,11 +488,9 @@ void AutoType::performGlobalAutoType(const QList<QSharedPointer<Database>>& dbLi
488488
m_windowForGlobal,
489489
virtualMode ? AutoTypeExecutor::Mode::VIRTUAL
490490
: AutoTypeExecutor::Mode::NORMAL);
491-
resetAutoTypeState();
492491
});
493492
connect(selectDialog, &QDialog::rejected, this, [this] {
494493
restoreWindowState();
495-
resetAutoTypeState();
496494
emit autotypeFinished();
497495
});
498496

@@ -506,10 +504,8 @@ void AutoType::performGlobalAutoType(const QList<QSharedPointer<Database>>& dbLi
506504
} else if (!matchList.isEmpty()) {
507505
// Only one match and not asking, do it!
508506
executeAutoTypeActions(matchList.first().first, matchList.first().second, m_windowForGlobal);
509-
resetAutoTypeState();
510507
} else {
511508
// We should never get here
512-
resetAutoTypeState();
513509
emit autotypeFinished();
514510
}
515511
}

src/autotype/AutoType.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public slots:
6666
private slots:
6767
void startGlobalAutoType(const QString& search);
6868
void unloadPlugin();
69+
void resetAutoTypeState();
6970

7071
private:
7172
enum WindowState
@@ -83,7 +84,6 @@ private slots:
8384
WId window = 0,
8485
AutoTypeExecutor::Mode mode = AutoTypeExecutor::Mode::NORMAL);
8586
void restoreWindowState();
86-
void resetAutoTypeState();
8787

8888
static QList<QSharedPointer<AutoTypeAction>>
8989
parseSequence(const QString& entrySequence, const Entry* entry, QString& error, bool syntaxOnly = false);

0 commit comments

Comments
 (0)