Commit 876099d8 authored by Eike Ziller's avatar Eike Ziller

DocumentModel: Avoid deletion of entries for suspended documents

When opening a previously suspended document, reuse the existing entry
instead of replacing it. That way existing pointers to the entry are not

Fixes a regression introduced by 0c441563
that lead to crashes when selecting suspended documents from the
history popup (ctrl+tab / opt+tab) with the mouse.

Change-Id: Id41cae1132e4435c8e8bbd8624eaf840b02dc31f
Reviewed-by: default avatarAlexandru Croitor <>
Reviewed-by: default avatarDavid Schulz <>
parent d21cd57e
......@@ -230,18 +230,14 @@ void DocumentModelPrivate::addEntry(DocumentModel::Entry *entry)
DocumentModel::Entry *previousEntry =;
const bool replace = !entry->isSuspended && previousEntry->isSuspended;
if (replace) {
delete previousEntry;
m_entries[previousIndex] = entry;
if (!fixedPath.isEmpty())
m_entryByFixedPath[fixedPath] = entry;
} else {
delete entry;
entry = previousEntry;
previousEntry->isSuspended = false;
delete previousEntry->document;
previousEntry->document = entry->document;
connect(previousEntry->document, &IDocument::changed, this, &DocumentModelPrivate::itemChanged);
previousEntry = 0;
if (replace)
connect(entry->document, &IDocument::changed, this, &DocumentModelPrivate::itemChanged);
delete entry;
entry = nullptr;
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