fix: [mdx] use file name as dictionary name when title has not been set

This commit is contained in:
YiFang Xiao 2024-10-28 00:04:53 +08:00
parent 15207cf400
commit 2ca5568b84

View file

@ -317,6 +317,12 @@ MdxDictionary::MdxDictionary( string const & id, string const & indexFile, vecto
dictionaryName = string( &buf.front(), len ); dictionaryName = string( &buf.front(), len );
} }
//fallback, use filename as dictionary name
if ( dictionaryName.empty() ) {
QFileInfo f( QString::fromUtf8( dictionaryFiles[ 0 ].c_str() ) );
dictionaryName = f.baseName().toStdString();
}
// then read the dictionary's encoding // then read the dictionary's encoding
len = idx.read< uint32_t >(); len = idx.read< uint32_t >();
if ( len > 0 ) { if ( len > 0 ) {