Skip to content

Commit bb4c957

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 4034c68 commit bb4c957

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
@@ -152,6 +152,7 @@ AutoType::AutoType(QObject* parent, bool test)
152152
#endif
153153
}
154154

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

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

355-
resetAutoTypeState();
356356
m_inAutoType.unlock();
357357
emit autotypeFinished();
358358
}
@@ -487,11 +487,9 @@ void AutoType::performGlobalAutoType(const QList<QSharedPointer<Database>>& dbLi
487487
m_windowForGlobal,
488488
virtualMode ? AutoTypeExecutor::Mode::VIRTUAL
489489
: AutoTypeExecutor::Mode::NORMAL);
490-
resetAutoTypeState();
491490
});
492491
connect(selectDialog, &QDialog::rejected, this, [this] {
493492
restoreWindowState();
494-
resetAutoTypeState();
495493
emit autotypeFinished();
496494
});
497495

@@ -505,10 +503,8 @@ void AutoType::performGlobalAutoType(const QList<QSharedPointer<Database>>& dbLi
505503
} else if (!matchList.isEmpty()) {
506504
// Only one match and not asking, do it!
507505
executeAutoTypeActions(matchList.first().first, matchList.first().second, m_windowForGlobal);
508-
resetAutoTypeState();
509506
} else {
510507
// We should never get here
511-
resetAutoTypeState();
512508
emit autotypeFinished();
513509
}
514510
}

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)