Handle the case if createSpeller is passed an unavailable language
ClosedPublic

Authored by ahmadsamir on Sun, Feb 10, 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
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
ahmadsamir requested review of this revision.Sun, Feb 10, 7:04 PM
ahmadsamir created this revision.
cullmann requested changes to this revision.Tue, Feb 12, 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.Tue, Feb 12, 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.Tue, Feb 12, 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.Tue, Feb 12, 9:54 PM

Ok, thought lang ist still lang.

This revision is now accepted and ready to land.Tue, Feb 12, 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.