mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-30 17:24:08 +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 )
|
QString Class::getAbbrName( QString const & text )
|
||||||
{
|
{
|
||||||
if ( text.isEmpty() )
|
if ( text.isEmpty() )
|
||||||
return QString();
|
return {};
|
||||||
//remove whitespace,number,mark,puncuation,symbol
|
//remove whitespace,number,mark,puncuation,symbol
|
||||||
QString simplified = text;
|
QString simplified = text;
|
||||||
simplified.remove(
|
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();
|
int index = qHash( simplified ) % simplified.size();
|
||||||
|
|
||||||
QString abbrName;
|
QString abbrName;
|
||||||
|
|
Loading…
Reference in a new issue