Fixes crash when deleting in search mode.

This commit is contained in:
Louis-Bertrand Varin 2017-03-04 12:19:18 -05:00
parent 37c9ad8e8d
commit b2fa6fca82
2 changed files with 12 additions and 5 deletions

View File

@ -322,8 +322,7 @@ void DatabaseWidget::cloneEntry()
Entry* entry = currentEntry->clone(Entry::CloneNewUuid | Entry::CloneResetTimeInfo | Entry::CloneRenameTitle); Entry* entry = currentEntry->clone(Entry::CloneNewUuid | Entry::CloneResetTimeInfo | Entry::CloneRenameTitle);
entry->setGroup(currentEntry->group()); entry->setGroup(currentEntry->group());
if (isInSearchMode()) refreshSearch();
search(m_lastSearchText);
m_entryView->setFocus(); m_entryView->setFocus();
m_entryView->setCurrentEntry(entry); m_entryView->setCurrentEntry(entry);
} }
@ -366,6 +365,7 @@ void DatabaseWidget::deleteEntries()
for (Entry* entry : asConst(selectedEntries)) { for (Entry* entry : asConst(selectedEntries)) {
delete entry; delete entry;
} }
refreshSearch();
} }
} }
else { else {
@ -875,6 +875,12 @@ void DatabaseWidget::databaseSaved()
m_databaseModified = false; m_databaseModified = false;
} }
void DatabaseWidget::refreshSearch() {
if (isInSearchMode()) {
search(m_lastSearchText);
}
}
void DatabaseWidget::search(const QString& searchtext) void DatabaseWidget::search(const QString& searchtext)
{ {
if (searchtext.isEmpty()) if (searchtext.isEmpty())
@ -908,9 +914,7 @@ void DatabaseWidget::search(const QString& searchtext)
void DatabaseWidget::setSearchCaseSensitive(bool state) void DatabaseWidget::setSearchCaseSensitive(bool state)
{ {
m_searchCaseSensitive = state; m_searchCaseSensitive = state;
refreshSearch();
if (isInSearchMode())
search(m_lastSearchText);
} }
void DatabaseWidget::onGroupChanged(Group* group) void DatabaseWidget::onGroupChanged(Group* group)

View File

@ -147,10 +147,12 @@ public Q_SLOTS:
void switchToImportKeepass1(const QString& fileName); void switchToImportKeepass1(const QString& fileName);
void databaseModified(); void databaseModified();
void databaseSaved(); void databaseSaved();
// Search related slots // Search related slots
void search(const QString& searchtext); void search(const QString& searchtext);
void setSearchCaseSensitive(bool state); void setSearchCaseSensitive(bool state);
void endSearch(); void endSearch();
void showMessage(const QString& text, MessageWidget::MessageType type); void showMessage(const QString& text, MessageWidget::MessageType type);
void hideMessage(); void hideMessage();
@ -177,6 +179,7 @@ private:
void setClipboardTextAndMinimize(const QString& text); void setClipboardTextAndMinimize(const QString& text);
void setIconFromParent(); void setIconFromParent();
void replaceDatabase(Database* db); void replaceDatabase(Database* db);
void refreshSearch();
Database* m_db; Database* m_db;
QWidget* m_mainWidget; QWidget* m_mainWidget;