Commit 6b8c0c33 authored by Francisco Boni Neto's avatar Francisco Boni Neto 🐼 Committed by Christoph Cullmann
Browse files

Fix crash when closing multiple tabs if limited number of tabs is enabled

Purge LRU storage must work regardless of CMAKE_BUILD_TYPE. Otherwise
KateTabBar::removeDocument will iterate over (m_docToLruCounterAndHasTab) documents (*doc) that
have been previously destroyed, resulting in segfault. Fixes Bug 450873
(https://bugs.kde.org/show_bug.cgi?id=450873).
BUG: 450873
parent bbfedcf2
Pipeline #142490 passed with stage
in 3 minutes and 9 seconds
......@@ -271,7 +271,7 @@ void KateTabBar::mouseMoveEvent(QMouseEvent *event)
paint.end();
auto parentViewSpace = qobject_cast<KateViewSpace *>(parentWidget());
Q_ASSERT(parentViewSpace);
if (!parentViewSpace) { qWarning() << Q_FUNC_INFO << "parentViewSpace is null"; }
auto view = parentViewSpace->currentView();
if (!view) {
......@@ -392,7 +392,8 @@ void KateTabBar::setCurrentDocument(KTextEditor::Document *doc)
void KateTabBar::removeDocument(KTextEditor::Document *doc)
{
// purge LRU storage, must work
Q_ASSERT(m_docToLruCounterAndHasTab.erase(doc) == 1);
auto erased = (m_docToLruCounterAndHasTab.erase(doc) == 1);
if (!erased) { qWarning() << Q_FUNC_INFO << "Failed to erase"; }
// remove document if needed, we might have no tab for it, if tab count is limited!
const int idx = documentIdx(doc);
......
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