mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-27 09:58:45 +01:00
Check for null return from getInfo(), the result when it tries to open
a corrupt dict. Such dicts should never get this far, but it doesn't hurt to be safe.
This commit is contained in:
parent
44c5500ab0
commit
4edca4ee4c
1 changed files with 18 additions and 11 deletions
|
@ -64,18 +64,19 @@ public class DictLangCache {
|
|||
|
||||
public static String annotatedDictName( Context context, DictAndLoc dal )
|
||||
{
|
||||
String result = null;
|
||||
DictInfo info = getInfo( context, dal );
|
||||
int wordCount = info.wordCount;
|
||||
if ( null != info ) {
|
||||
int wordCount = info.wordCount;
|
||||
|
||||
String langName = getLangName( context, dal.name );
|
||||
String result;
|
||||
if ( 0 == wordCount ) {
|
||||
result = String.format( "%s (%s)", dal.name, langName );
|
||||
} else {
|
||||
result = String.format( "%s (%s/%d)", dal.name, langName,
|
||||
wordCount );
|
||||
String langName = getLangName( context, dal.name );
|
||||
if ( 0 == wordCount ) {
|
||||
result = String.format( "%s (%s)", dal.name, langName );
|
||||
} else {
|
||||
result = String.format( "%s (%s/%d)", dal.name, langName,
|
||||
wordCount );
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -114,7 +115,7 @@ public class DictLangCache {
|
|||
DictAndLoc[] dals = DictUtils.dictList( context );
|
||||
for ( DictAndLoc dal : dals ) {
|
||||
DictInfo info = getInfo( context, dal );
|
||||
if ( code == info.langCode ) {
|
||||
if ( null != info && code == info.langCode ) {
|
||||
al.add( info );
|
||||
}
|
||||
}
|
||||
|
@ -159,7 +160,7 @@ public class DictLangCache {
|
|||
DictAndLoc[] dals = DictUtils.dictList( context );
|
||||
for ( DictAndLoc dal : dals ) {
|
||||
DictInfo info = getInfo( context, dal );
|
||||
if ( code == info.langCode ) {
|
||||
if ( null != info && code == info.langCode ) {
|
||||
al.add( dal );
|
||||
}
|
||||
}
|
||||
|
@ -373,6 +374,12 @@ public class DictLangCache {
|
|||
|
||||
info = new DictInfo();
|
||||
|
||||
// It should not be possible for dict_getInfo to fail
|
||||
// unless DictUtils.dictList() isn't doing its job and
|
||||
// puts unchecked dicts on the list. Should probably
|
||||
// assert that this returns true. Open question: do I
|
||||
// always trust dicts in the BUILTIN and INTERNAL
|
||||
// locations? Files can get damaged....
|
||||
if ( XwJNI.dict_getInfo( pairs.m_bytes[0], pairs.m_paths[0],
|
||||
JNIUtilsImpl.get(),
|
||||
DictUtils.DictLoc.DOWNLOAD == dal.loc,
|
||||
|
|
Loading…
Reference in a new issue