Changeset View
Changeset View
Standalone View
Standalone View
src/core/loader.cpp
Show First 20 Lines • Show All 83 Lines • ▼ Show 20 Line(s) | |||||
84 | SpellerPlugin *Loader::createSpeller(const QString &language, const QString &clientName) const | 84 | SpellerPlugin *Loader::createSpeller(const QString &language, const QString &clientName) const | ||
85 | { | 85 | { | ||
86 | QString backend = clientName; | 86 | QString backend = clientName; | ||
87 | QString plang = language; | 87 | QString plang = language; | ||
88 | 88 | | |||
89 | if (plang.isEmpty()) { | 89 | if (plang.isEmpty()) { | ||
90 | plang = d->settings->defaultLanguage(); | 90 | plang = d->settings->defaultLanguage(); | ||
91 | } | 91 | } | ||
92 | const QVector<Client *> lClients = d->languageClients[plang]; | | |||
93 | 92 | | |||
94 | if (lClients.isEmpty()) { | 93 | // make sure plang is one of languages(), otherwise calling | ||
94 | // d->languageClients[plang] will create a default-constructed value | ||||
95 | // for it and it doesn't have any dictionaries to begin with | ||||
96 | if (!languages().contains(plang)) { | ||||
95 | qCWarning(SONNET_LOG_CORE) << "No language dictionaries for the language:" << plang; | 97 | qCWarning(SONNET_LOG_CORE) << "No language dictionaries for the language:" << plang; | ||
98 | emit loadingDictionaryFailed(plang); | ||||
96 | return nullptr; | 99 | return nullptr; | ||
97 | } | 100 | } | ||
98 | 101 | | |||
102 | const QVector<Client *> lClients = d->languageClients[plang]; | ||||
103 | | ||||
99 | if (backend.isEmpty()) { | 104 | if (backend.isEmpty()) { | ||
100 | backend = d->settings->defaultClient(); | 105 | backend = d->settings->defaultClient(); | ||
101 | if (!backend.isEmpty()) { | 106 | if (!backend.isEmpty()) { | ||
102 | // check if the default client supports the requested language; | 107 | // check if the default client supports the requested language; | ||
103 | // if it does it will be an element of lClients. | 108 | // if it does it will be an element of lClients. | ||
104 | bool unknown = !std::any_of(lClients.constBegin(), lClients.constEnd(), [backend] (const Client *client) { | 109 | bool unknown = !std::any_of(lClients.constBegin(), lClients.constEnd(), [backend] (const Client *client) { | ||
105 | return client->name() == backend; }); | 110 | return client->name() == backend; }); | ||
106 | if (unknown) { | 111 | if (unknown) { | ||
▲ Show 20 Lines • Show All 254 Lines • Show Last 20 Lines |