Skip to content

word counter: check if internal state is consistent with document state

Ilia Kats requested to merge work/ilia/wordcounter_crashes into kf5

Inconsistent state can lead to crashes. This can occur when signals from KTextEditor::Document are temporarily blocked by the application. KBibTex does this. To reproduce the crash open any bibliography entry in KBibTex, go to the "Source" tab, focus the text editor, and press Enter twice to add two new lines.

This patch prevents crashes. The word count information is still incorrect directly after opening the "Source" tab, but I don't think KTextEditor should be responsible for other apps using it in this way.

I've only tested with kf5, but since there are zero differences between the k5 and master versions of the wordcount plugin, I expect the issue and fix to also apply to master. Happy to cherry-pick the commit.

Merge request reports