Merge pull request #1061 from xiaoyifang/fix/crash-abbr

fix: generate icon name crash with 0 size
This commit is contained in:
xiaoyifang 2023-08-11 10:33:05 +08:00 committed by GitHub
commit 8ac4669c2f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;