ViewSpace: Don't ASSERT, just check for valid doc to remove from tab
ClosedPublic

Authored by loh.tar on Apr 22 2019, 7:34 AM.

Details

Summary

The same ASSERT is done in removeTab(..) but at this point here was observed that it could happens, e.g. while session restore

Diff Detail

Repository
R40 Kate
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
loh.tar created this revision.Apr 22 2019, 7:34 AM
Restricted Application added a project: Kate. · View Herald TranscriptApr 22 2019, 7:34 AM
Restricted Application added a subscriber: kwrite-devel. · View Herald Transcript
loh.tar requested review of this revision.Apr 22 2019, 7:34 AM

Out of the blue run I into this issue.
The only slightly unusual before was, that I had a confirmation box regarding an unsaved file while quit the session. Then, when I want to restart the same session, it crached always.
If you like I can submit the BT, but think it's not needed to approve this patch.

Hmm, the internal state is really broken if that doesn't work.
I don't think this check will really solve the issue.
Had you any chance to see a backtrace with e.g. the index?

Hmm, perhaps the restore view stuff does create the issues:

// restore Document lru list so that all tabs from the last session reappear
 const QStringList lruList = group.readEntry("Documents", QStringList());
 for (int i = 0; i < lruList.size(); ++i) {
     auto doc = KateApp::self()->documentManager()->findDocument(QUrl(lruList[i]));
     if (doc) {
         const int index = m_lruDocList.indexOf(doc);
         if (index < 0) {
             registerDocument(doc);
             Q_ASSERT(m_lruDocList.contains(doc));
         } else {
             m_lruDocList.removeAt(index);
             m_lruDocList.append(doc);
         }
     }
 }

the else case with the lruDocList changes might mess up some lru => tab order, or?

cullmann added a comment.EditedApr 22 2019, 4:29 PM

I would propose this fix:

hm, can't say much helpful to your patch. Send you my BT.
But from my point of view is this assert here redundant. When you dislike my check, you can drop the assert anyway.

I'm sorry, I couldn't reproduce the crash to verify your patch. But at least cause it on the first sight no new crash here :-)

cullmann accepted this revision.Apr 23 2019, 5:00 AM

Then we try that patch in master.
I think re-shuffling the indices there is no good idea.

This revision is now accepted and ready to land.Apr 23 2019, 5:00 AM
This revision was automatically updated to reflect the committed changes.