Merge pull request #1876 from xiaoyifang/fix/mdx-empty-title
Some checks are pending
SonarCloud / Build and analyze (push) Waiting to run

fix: [mdx] use file name as  dictionary name when title has not been set
This commit is contained in:
xiaoyifang 2024-10-28 08:36:03 +08:00 committed by GitHub
commit 12dbfb5423
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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 ) {