Commit 8eb22551 authored by Kåre Särs's avatar Kåre Särs

Fix a crash when documents are closed before a new search.

parent 139d2b20
......@@ -243,6 +243,9 @@ m_curResults(0)
connect(m_kateApp->documentManager(), SIGNAL(documentWillBeDeleted(KTextEditor::Document*)),
&m_replacer, SLOT(cancelReplace()));
connect(m_kateApp->documentManager(), SIGNAL(documentWillBeDeleted(KTextEditor::Document*)),
this, SLOT(clearDocMarks(KTextEditor::Document*)));
connect(&m_replacer, SIGNAL(matchReplaced(KTextEditor::Document*,int,int,int)),
this, SLOT(addMatchMark(KTextEditor::Document*,int,int,int)));
......@@ -514,6 +517,36 @@ void KatePluginSearchView::clearMarks()
m_matchRanges.clear();
}
void KatePluginSearchView::clearDocMarks(KTextEditor::Document* doc)
{
//kDebug() << sender();
// FIXME: check for ongoing search...
KTextEditor::MarkInterface* iface;
iface = qobject_cast<KTextEditor::MarkInterface*>(doc);
if (iface) {
const QHash<int, KTextEditor::Mark*> marks = iface->marks();
QHashIterator<int, KTextEditor::Mark*> i(marks);
while (i.hasNext()) {
i.next();
if (i.value()->type == KTextEditor::MarkInterface::markType32) {
iface->removeMark(i.value()->line, i.value()->type);
}
}
}
int i = 0;
while (i<m_matchRanges.size()) {
if (m_matchRanges.at(i)->document() == doc) {
//kDebug() << "removing mark in" << doc->url();
delete m_matchRanges.at(i);
m_matchRanges.removeAt(i);
}
else {
i++;
}
}
}
void KatePluginSearchView::searchDone()
{
......
......@@ -110,6 +110,7 @@ private Q_SLOTS:
void itemSelected(QTreeWidgetItem *item);
void clearMarks();
void clearDocMarks(KTextEditor::Document* doc);
void replaceChecked();
......@@ -133,7 +134,7 @@ private:
KAction *m_matchCase;
KAction *m_useRegExp;
Results *m_curResults;
QVector<KTextEditor::MovingRange*> m_matchRanges;
QList<KTextEditor::MovingRange*> m_matchRanges;
};
class KateSearchCommand : public QObject, public KTextEditor::Command
......
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