Make automatic spellcheck work after reloading a document
ClosedPublic

Authored by ahmadsamir on Jun 20 2019, 4:43 PM.

Details

Summary

When a document gets reloaded for whatever reason, automatic spellcheck
should be refreshed so as to re-process the document contents.

BUG: 408291
FIXED-IN: 5.61.0

Test Plan
  • Open a document - with a couple of misspelled words - in kate
  • Enable "automatic spell checking"
  • Reload the document
  • The misspelled words in the document should be higlighted after reloading

Diff Detail

Repository
R39 KTextEditor
Branch
document-reloaded-spellcheck (branched from master)
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 13213
Build 13231: arc lint + arc unit
ahmadsamir created this revision.Jun 20 2019, 4:43 PM
Restricted Application added projects: Kate, Frameworks. · View Herald TranscriptJun 20 2019, 4:43 PM
ahmadsamir requested review of this revision.Jun 20 2019, 4:43 PM
dhaumann requested changes to this revision.Jun 21 2019, 6:10 AM
dhaumann added a subscriber: dhaumann.

You don't need the extra function. Could you update the patch?

src/spellcheck/ontheflycheck.cpp
75 ↗(On Diff #60154)

Directly connect to this, refreshSpellCheck.

src/spellcheck/ontheflycheck.h
71 ↗(On Diff #60154)

Please delete this function complete, see next comment.

This revision now requires changes to proceed.Jun 21 2019, 6:10 AM
ahmadsamir added inline comments.Jun 21 2019, 8:23 AM
src/spellcheck/ontheflycheck.cpp
75 ↗(On Diff #60154)

That wouldn't work, reloaded() takes a Document pointer parameter whereas refreshSpellcheck takes a Range parameter.

dhaumann added inline comments.Jun 21 2019, 1:13 PM
src/spellcheck/ontheflycheck.cpp
75 ↗(On Diff #60154)

But refreshSpellCheck() has a default parameter, so this function exists without any parameter. Afaik this should work?!

ahmadsamir added inline comments.Jun 21 2019, 1:39 PM
src/spellcheck/ontheflycheck.cpp
75 ↗(On Diff #60154)
In file included from /usr/include/qt5/QtCore/qalgorithms.h:43,
                 from /usr/include/qt5/QtCore/qlist.h:43,
                 from /usr/include/qt5/QtCore/QList:1,
                 from /home/ahmad/dev/ktexteditor/git/src/spellcheck/ontheflycheck.h:25,
                 from /home/ahmad/dev/ktexteditor/git/src/spellcheck/ontheflycheck.cpp:26:
/usr/include/qt5/QtCore/qobject.h: In instantiation of ‘static QMetaObject::Connection QObject::connect(const typename QtPrivate::FunctionPointer<Func>::Object*, Func1, const typename QtPrivate::FunctionPointer<Func2>::Object*, Func2, Qt::ConnectionType) [with Func1 = void (KTextEditor::Document::*)(KTextEditor::Document*); Func2 = void (KateOnTheFlyChecker::*)(const KTextEditor::Range&); typename QtPrivate::FunctionPointer<Func>::Object = KTextEditor::Document; typename QtPrivate::FunctionPointer<Func2>::Object = KateOnTheFlyChecker]’:
/home/ahmad/dev/ktexteditor/git/src/spellcheck/ontheflycheck.cpp:76:58:   required from here
/usr/include/qt5/QtCore/qobject.h:241:9: error: static assertion failed: Signal and slot arguments are not compatible.
  241 |         Q_STATIC_ASSERT_X((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value),
      |         ^~~~~~~~~~~~~~~~~

Qt docs say that the signal must have at least as many arguments as the slot, and there is an implicit conversion between the types of the corresponding arguments in the signal and the slot.

dhaumann added inline comments.Jun 22 2019, 8:27 PM
src/spellcheck/ontheflycheck.cpp
75 ↗(On Diff #60154)

In that case, please use an anonymous lambda:

[this](KTextEditor:: Document*){refreshSpellCheck ();}

That keeps the code closer together.

ahmadsamir removed a subscriber: dhaumann.

Use a lambda instead of adding a standalone method

ahmadsamir marked 5 inline comments as done.Jun 23 2019, 12:09 PM
dhaumann accepted this revision.Jun 23 2019, 12:37 PM

Looks good to me now :)

This revision is now accepted and ready to land.Jun 23 2019, 12:37 PM

Great :). Please commit it too (as I don't have access to kde git).

This revision was automatically updated to reflect the committed changes.