Skip to content

Commit

Permalink
ui: Immediately delete unused QSeletionModels
Browse files Browse the repository at this point in the history
This is a workaround for QTBUG-49966, as we don't want to keep
replaced selection models around.
  • Loading branch information
trollixx committed Jan 21, 2018
1 parent 2a2627a commit 1433063
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/libs/ui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,15 +551,21 @@ void MainWindow::duplicateTab(int index)

void MainWindow::syncTreeView()
{
TabState *tabState = currentTabState();
QItemSelectionModel *oldSelectionModel = ui->treeView->selectionModel();

if (!tabState->searchQuery.isEmpty()) {
ui->treeView->setModel(tabState->searchModel);
ui->treeView->setRootIsDecorated(false);
} else {
TabState *tabState = currentTabState();
if (tabState->searchQuery.isEmpty()) {
ui->treeView->setModel(m_zealListModel);
ui->treeView->setColumnHidden(1, true);
ui->treeView->setRootIsDecorated(true);
} else {
ui->treeView->setModel(tabState->searchModel);
ui->treeView->setRootIsDecorated(false);
}

// TODO: Remove once QTBUG-49966 is addressed.
QItemSelectionModel *newSelectionModel = ui->treeView->selectionModel();
if (oldSelectionModel && newSelectionModel != oldSelectionModel) {
oldSelectionModel->deleteLater();
}

ui->treeView->reset();
Expand Down

0 comments on commit 1433063

Please sign in to comment.