mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 15:24:05 +00:00
Merge pull request #1061 from xiaoyifang/fix/crash-abbr
fix: generate icon name crash with 0 size
This commit is contained in:
commit
8ac4669c2f
|
@ -335,11 +335,14 @@ bool Class::loadIconFromText( QString iconUrl, QString const & text )
|
|||
QString Class::getAbbrName( QString const & text )
|
||||
{
|
||||
if ( text.isEmpty() )
|
||||
return QString();
|
||||
return {};
|
||||
//remove whitespace,number,mark,puncuation,symbol
|
||||
QString simplified = text;
|
||||
simplified.remove(
|
||||
QRegularExpression( "[\\p{Z}\\p{N}\\p{M}\\p{P}\\p{S}]", QRegularExpression::UseUnicodePropertiesOption ) );
|
||||
QRegularExpression( R"([\p{Z}\p{N}\p{M}\p{P}\p{S}])", QRegularExpression::UseUnicodePropertiesOption ) );
|
||||
|
||||
if ( simplified.isEmpty() )
|
||||
return {};
|
||||
int index = qHash( simplified ) % simplified.size();
|
||||
|
||||
QString abbrName;
|
||||
|
|
Loading…
Reference in a new issue