Commit b590c097 authored by Milian Wolff's avatar Milian Wolff

Fix crash on access of Document::defStyleNum without active view.

BUG: 337229
(cherry picked from commit a8df8a55)
parent 92a45720
......@@ -5488,11 +5488,16 @@ int KateDocument::defStyleNum(int line, int column)
} else
return -1;
KateView* view = static_cast<KateView*>(activeView());
if (!view && !m_views.isEmpty()) {
view = m_views.first();
} else {
//FIXME: find a way to use this function without any view, or move it to the KateView.
return -1;
}
QList<KTextEditor::Attribute::Ptr> attributes = highlight()->attributes(
static_cast<KateView*>(activeView())
->renderer()
->config()
->schema()
view->renderer()->config()->schema()
);
// sanity check for the attribute
......
......@@ -345,4 +345,11 @@ void KateDocumentTest::testDigest()
QCOMPARE(docDigest, fileDigest);
}
void KateDocumentTest::testDefStyleNum()
{
KateDocument doc;
doc.setText("foo\nbar\nasdf");
QCOMPARE(doc.defStyleNum(0, 0), -1);
}
#include "katedocument_test.moc"
......@@ -44,6 +44,8 @@ private Q_SLOTS:
void testInsertNewline();
void testDigest();
void testDefStyleNum();
};
#endif // KATE_DOCUMENT_TEST_H
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