Commit 8c7011c8 authored by Thomas Friedrichsmeier's avatar Thomas Friedrichsmeier
Browse files

Do not assume that list of documents is non-empty

Summary: Host applications may not always have an active view, and a non-empty list of documents. This would currently crash when clicking the "Search"-button with "Current File" or "Open Files".

Test Plan: Tested with plugin loaded in RKWard, and no documents present. Segfault without patch, no matches, with patch.

Reviewers: cullmann, sars

Reviewed By: cullmann, sars

Subscribers: sars, kwrite-devel

Tags: #kate

Differential Revision: https://phabricator.kde.org/D26620
parent 007a7aef
......@@ -1095,7 +1095,10 @@ void KatePluginSearchView::startSearch()
m_searchDiskFilesDone = true;
m_resultBaseDir.clear();
QList<KTextEditor::Document *> documents;
documents << m_mainWindow->activeView()->document();
KTextEditor::View *activeView = m_mainWindow->activeView();
if (activeView) {
documents << activeView->document();
}
addHeaderItem();
m_searchOpenFiles.startSearch(documents, reg);
} else if (m_ui.searchPlaceCombo->currentIndex() == OpenFiles) {
......
......@@ -53,7 +53,7 @@ void SearchOpenFiles::cancelSearch()
void SearchOpenFiles::doSearchNextFile(int startLine)
{
if (m_cancelSearch) {
if (m_cancelSearch || m_nextIndex >= m_docList.size()) {
m_nextIndex = -1;
m_cancelSearch = true;
emit searchDone();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment