fix(ui): fix crash on tab duplication

The crash occurred when there were selected items in the tree view.
This commit is contained in:
Oleg Shparber 2020-09-08 03:09:04 -04:00
parent 803db6ae34
commit 5220b7093e

View File

@ -148,10 +148,15 @@ SearchSidebar::SearchSidebar(const SearchSidebar *other, QWidget *parent)
setTreeViewModel(m_searchModel, false);
}
// Clone current selection. Signals must be disabled to avoid crash in the event handler.
m_treeView->selectionModel()->blockSignals(true);
for (const QModelIndex &index : other->m_treeView->selectionModel()->selectedIndexes()) {
m_treeView->selectionModel()->select(index, QItemSelectionModel::Select);
}
m_treeView->selectionModel()->blockSignals(false);
// Cannot update position until layout geomentry is calculated, so set it in showEvent().
m_pendingVerticalPosition = other->m_treeView->verticalScrollBar()->value();
} else {