Reuse unmodified empty document instead of closing it
ClosedPublic

Authored by croick on Nov 8 2017, 12:46 AM.

Details

Summary
  • In VI-Mode, using :e filename or :tabe filename in the empty unmodified initial document makes Kate crash. The caller is deleted by closing the document.
  • Reusing the already opened document avoids the problem.
Test Plan
  • use :e filename in VI-Mode from a fresh kate instance

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.
croick created this revision.Nov 8 2017, 12:46 AM
Restricted Application added a project: Kate. · View Herald TranscriptNov 8 2017, 12:46 AM

Hmm, isn't there some potential problem that the next call might use that untitled document again before the event loop call happens and we close it then?
Perhaps a better fix would be to defer the open call in the vi mode?

Hmm, isn't there some potential problem that the next call might use that untitled document again before the event loop call happens and we close it then?
Perhaps a better fix would be to defer the open call in the vi mode?

That might happen, yes. Deferring the open call is probably not an option, since the return value is used. Maybe one could remove the document and its view from all of the lists but call deleteLater() instead of delete. Somehow this already sounds like a hack though.

Hmm, perhaps a different approach would fix the issue:

Instead of creating a new document and closing untitled afterwards, perhaps just use untitled for the opening.
Then you get no race anymore.

Could you try that out?

cullmann requested changes to this revision.Nov 13 2017, 7:59 PM

Please give my idea an try, if you don't find an obvious flaw in it.

Besides: Thanks already for caring about the crashs!

This revision now requires changes to proceed.Nov 13 2017, 7:59 PM
croick updated this revision to Diff 22418.Nov 15 2017, 10:40 PM
  • reuse untitled document instead of closing it
croick retitled this revision from Defer automatic closing of unmodified empty document to event loop to Reuse unmodified empty document instead of closing it.Nov 15 2017, 10:41 PM
croick edited the summary of this revision. (Show Details)
croick updated this revision to Diff 22419.Nov 15 2017, 10:46 PM
  • don't look for the document info twice
cullmann accepted this revision.Nov 16 2017, 6:51 AM

If that change does the trick for you, feel free to push this.
This avoids any race-conditions we would introduce with the single shot variant.

This revision is now accepted and ready to land.Nov 16 2017, 6:51 AM
This revision was automatically updated to reflect the committed changes.