Commit cbe04fba authored by Christoph Cullmann's avatar Christoph Cullmann 🍨
Browse files

catch another crash with empty view space

add matching test
parent 04bf8b65
Pipeline #230606 passed with stage
in 5 minutes and 52 seconds
......@@ -170,3 +170,20 @@ void KateViewManagementTests::testTwoMainWindowsCloseInitialDocument2()
// create a new document, this did crash due to empty view space
second->viewManager()->slotDocumentNew();
}
void KateViewManagementTests::testTwoMainWindowsCloseInitialDocument3()
{
// get first main window
KateMainWindow *first = app->activeKateMainWindow();
QVERIFY(first);
// create a second one
KateMainWindow *second = app->newMainWindow();
QVERIFY(second);
// close the initial document tab in second window
second->viewManager()->closeView(second->viewManager()->activeView());
// create a new document, this did crash due to empty view space
second->viewManager()->slotDocumentNew();
}
......@@ -30,6 +30,7 @@ private Q_SLOTS:
void testMoveViewBetweenViewspaces();
void testTwoMainWindowsCloseInitialDocument1();
void testTwoMainWindowsCloseInitialDocument2();
void testTwoMainWindowsCloseInitialDocument3();
private:
class QTemporaryDir *m_tempdir;
......
......@@ -300,8 +300,10 @@ void KateViewSpace::urlBarToggled(bool show)
KTextEditor::View *KateViewSpace::createView(KTextEditor::Document *doc)
{
// should only be called if a view does not yet exist
Q_ASSERT(m_docToView.find(doc) == m_docToView.end());
// do nothing if we already have some view
if (const auto it = m_docToView.find(doc); it != m_docToView.end()) {
return it->second;
}
/**
* Create a fresh view
......
Supports Markdown
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