forked from qt-creator/qt-creator
FancyLineEdit: Do not overwrite content with non-existing history data
Change-Id: Ia51417b599e0e3847a0ade54ab5633c87c2ab48c Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -302,7 +302,7 @@ void FancyLineEdit::setHistoryCompleter(const QString &historyKey, bool restoreL
|
||||
{
|
||||
QTC_ASSERT(!d->m_historyCompleter, return);
|
||||
d->m_historyCompleter = new HistoryCompleter(historyKey, this);
|
||||
if (restoreLastItemFromHistory)
|
||||
if (restoreLastItemFromHistory && d->m_historyCompleter->hasHistory())
|
||||
setText(d->m_historyCompleter->historyItem());
|
||||
QLineEdit::setCompleter(d->m_historyCompleter);
|
||||
|
||||
|
@@ -46,6 +46,7 @@ public:
|
||||
HistoryCompleter(const QString &historyKey, QObject *parent = nullptr);
|
||||
bool removeHistoryItem(int index);
|
||||
QString historyItem() const;
|
||||
bool hasHistory() const { return historySize() > 0; }
|
||||
static bool historyExistsFor(const QString &historyKey);
|
||||
|
||||
private:
|
||||
|
Reference in New Issue
Block a user