mirror of
https://github.com/zealdocs/zeal.git
synced 2024-11-27 11:44:56 +03:00
ui: Fix crash when docsets in the current search are removed
This commit is contained in:
parent
73ecfb944c
commit
c25abbee6f
@ -336,27 +336,29 @@ MainWindow::MainWindow(Core::Application *app, QWidget *parent) :
|
|||||||
currentTabState()->searchModel->setResults(results);
|
currentTabState()->searchModel->setResults(results);
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(m_application->docsetRegistry(), &Registry::DocsetRegistry::docsetRemoved,
|
connect(m_application->docsetRegistry(), &Registry::DocsetRegistry::docsetAboutToBeRemoved,
|
||||||
this, [this](const QString &name) {
|
this, [this](const QString &name) {
|
||||||
setupSearchBoxCompletions();
|
|
||||||
for (TabState *tabState : m_tabStates) {
|
for (TabState *tabState : m_tabStates) {
|
||||||
if (docsetName(tabState->url()) != name)
|
if (tabState == currentTabState()) {
|
||||||
continue;
|
// Disable updates because removeSearchResultWithName can
|
||||||
|
// call {begin,end}RemoveRows multiple times, and cause
|
||||||
|
// degradation of UI responsiveness.
|
||||||
|
ui->treeView->setUpdatesEnabled(false);
|
||||||
|
tabState->searchModel->removeSearchResultWithName(name);
|
||||||
|
ui->treeView->setUpdatesEnabled(true);
|
||||||
|
} else {
|
||||||
|
tabState->searchModel->removeSearchResultWithName(name);
|
||||||
|
}
|
||||||
|
|
||||||
tabState->tocModel->setResults();
|
if (docsetName(tabState->url()) == name) {
|
||||||
|
tabState->tocModel->setResults();
|
||||||
// optimization: disable updates temporarily because
|
tabState->loadUrl(QUrl(startPageUrl));
|
||||||
// removeSearchResultWithName can call {begin,end}RemoveRows
|
}
|
||||||
// multiple times which can cause GUI updates to be suboptimal
|
|
||||||
// in case of many rows to be removed
|
|
||||||
ui->treeView->setUpdatesEnabled(false);
|
|
||||||
tabState->searchModel->removeSearchResultWithName(name);
|
|
||||||
ui->treeView->setUpdatesEnabled(true);
|
|
||||||
|
|
||||||
tabState->loadUrl(QUrl(startPageUrl));
|
|
||||||
|
|
||||||
// TODO: Cleanup history
|
// TODO: Cleanup history
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setupSearchBoxCompletions();
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(m_application->docsetRegistry(), &Registry::DocsetRegistry::docsetAdded,
|
connect(m_application->docsetRegistry(), &Registry::DocsetRegistry::docsetAdded,
|
||||||
|
Loading…
Reference in New Issue
Block a user