Bug 311704 - kde4libs-4.9.4/sonnet/plugins/hspell adds spell check language "Hebrew" to language list, even if hspell is not installed
Summary: kde4libs-4.9.4/sonnet/plugins/hspell adds spell check language "Hebrew" to la...
Status: RESOLVED FIXED
Alias: None
Product: kdelibs
Classification: Frameworks and Libraries
Component: kspell (show other bugs)
Version: 4.9.4
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-14 17:46 UTC by Thomas Dreibholz
Modified: 2012-12-15 10:21 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.9.5


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Dreibholz 2012-12-14 17:46:17 UTC
At least on a Kubuntu system with language support for English, Bokmål and German, there is always also Hebrew as language in the spell checker's language list. This can be reprocuded by just running "kcmshell4 spellchecking". The problem is that kde4libs-4.9.4/sonnet/plugins/hspell produces a library with has statically linked the libhspell (Hebrew spell checker library). It is then installed as /usr/lib/kde4/kspell_hspell.so. This library always adds "Hebrew" to the language list, regardless of an existing installation of the corresponding hspell dictionary files.

The problem is in kspell_hspellclient.cpp:

QStringList HSpellClient::languages() const
{
    QStringList langs;
    langs.append( "he" );

    return langs;
}

There is no check whether libhspell successfully initializes. Instead, the additional language is just added.

The following patch fixes the problem, by just adding the necessary check:

diff -urb hspell.orig/kspell_hspellclient.cpp hspell/kspell_hspellclient.cpp
--- hspell.orig/kspell_hspellclient.cpp	2012-12-14 13:06:08.000000000 +0100
+++ hspell/kspell_hspellclient.cpp	2012-12-14 18:21:43.000000000 +0100
@@ -51,7 +51,11 @@
 QStringList HSpellClient::languages() const
 {
     QStringList langs;
+    HSpellDict *ad = new HSpellDict("he");
+    if (ad->isInitialized()) {
     langs.append( "he" );
+       delete ad;
+    }

     return langs;
 }
diff -urb hspell.orig/kspell_hspelldict.h hspell/kspell_hspelldict.h
--- hspell.orig/kspell_hspelldict.h	2012-12-14 13:06:08.000000000 +0100
+++ hspell/kspell_hspelldict.h	2012-12-14 13:06:51.000000000 +0100
@@ -42,6 +42,7 @@

     virtual bool addToPersonal( const QString& word );
     virtual bool addToSession( const QString& word );
+    inline bool isInitialized() { return initialized; }
 private:
     struct dict_radix *m_speller;
     QTextCodec *codec;

In this case, the spell check functionality is only provided if hspell with its dictionaries is actually installed.

Reproducible: Always

Steps to Reproduce:
1. Run "kcmshell4 spellchecking" and check the language list.
2. The language "Hebrew" is provided in the list, regardless of the installation of the corresponding spell checker "hspell".



Expected Results:  
The language "Hebrew" should only be provided in the spell checker language list if "hspell" is installed.

kspell_hspell statically links the libhspell.a, i.e. the full libhspell functionality gets installed with every system. This is not very useful; it should be linked dynamically.

Furthermore, if kspell_enchant is also installed, and "enchant" compiled with hspell support, it adds again a copy of the static libhspell.a code.

And, if hspell is actually installed on a system, it will contain the third copy of that code.
Comment 1 Laurent Montel 2012-12-15 10:20:29 UTC
Git commit 0713df9c5cf246c589444eb062900c655f6d7977 by Montel Laurent.
Committed on 15/12/2012 at 11:19.
Pushed by mlaurent into branch 'KDE/4.9'.

Fix Bug 311704 - kde4libs-4.9.4/sonnet/plugins/hspell adds spell check

language "Hebrew" to language list, even if hspell is not installed

Apply patch from  Thomas Dreibholz  Thanks.

FIXED-IN: 4.9.5

M  +5    -2    sonnet/plugins/hspell/kspell_hspellclient.cpp
M  +1    -0    sonnet/plugins/hspell/kspell_hspelldict.h

http://commits.kde.org/kdelibs/0713df9c5cf246c589444eb062900c655f6d7977