Handle the case if createSpeller is passed an unavailable language
ClosedPublic

Authored by ahmadsamir on Feb 10 2019, 7:04 PM.

Details

Summary

In Loader::createSpeller, retun early if lang isn't one of the available
languages(); otherwise a dud entry will be created for it in
dictionarycombobox.

Emit a signal when loading a dictionary fails, so that Ui parts can
display an appropriate error message informing the user about the issue,
instead of failing silently.

This is a first step to fix bug 325541.

Diff Detail

Repository
R246 Sonnet
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 8225
Build 8243: arc lint + arc unit
ahmadsamir requested review of this revision.Feb 10 2019, 7:04 PM
ahmadsamir created this revision.
cullmann requested changes to this revision.Feb 12 2019, 7:32 PM

I think the const at the end for the signal is not wanted, otherwise, this seems to make sense for me.

I would appreciate a comment what the "lang" param is and that "lang" is "language", we don't need to shorten that in the API.

Code-wise:

Could you not just use "find" on the d->languageClients and check the iterator? That way we avoid searching twice (in different data structures).

This revision now requires changes to proceed.Feb 12 2019, 7:32 PM

I think the const at the end for the signal is not wanted, otherwise, this seems to make sense for me.

The this pointer of Loader::createSpeller is const, so the signal has to be const.

In member function ‘Sonnet::SpellerPlugin* Sonnet::Loader::createSpeller(const QString&, const QString&) const’:
/home/ahmad/rpmbuild/kf5-sonnet/git/src/core/loader.cpp:98:43: error: passing ‘const Sonnet::Loader’ as ‘this’ argument discards qualifiers [-fpermissive]
         emit loadingDictionaryFailed(plang);

I would appreciate a comment what the "lang" param is and that "lang" is "language", we don't need to shorten that in the API.

Yes, of course.

Code-wise:

Could you not just use "find" on the d->languageClients and check the iterator? That way we avoid searching twice (in different data structures).

Makes, much, more sense. Will do.

ahmadsamir updated this revision to Diff 51552.Feb 12 2019, 9:16 PM

Improve api docs.
Use constFind() with languageClients, as that's more efficient than searching two separate data structures.

cullmann accepted this revision.Feb 12 2019, 9:54 PM

Ok, thought lang ist still lang.

This revision is now accepted and ready to land.Feb 12 2019, 9:54 PM

Avoid shorthand in api docs

I don't have commit access, so please commit the diff.

Thanks.

This revision was automatically updated to reflect the committed changes.