Skip to content

Commit

Permalink
Return an empty QStringList if the family string is empty
Browse files Browse the repository at this point in the history
Since doing a split will create an empty entry, then we can save time
and just return an empty QStringList in this case

Change-Id: I86a6532e7243151493ea4021bfcc05e4c2a9cbf0
Reviewed-by: Fabian Kosmale <[email protected]>
  • Loading branch information
AndyShawQt committed Nov 27, 2020
1 parent c7a3358 commit 420e27c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/gui/text/qfont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ static int convertWeights(int weight, bool inverted)
static QStringList splitIntoFamilies(const QString &family)
{
QStringList familyList;
if (family.isEmpty())
return familyList;
const auto list = QStringView{family}.split(QLatin1Char(','));
const int numFamilies = list.size();
familyList.reserve(numFamilies);
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/accessible/qaccessiblewidgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ QString QAccessibleTextWidget::attributes(int offset, int *startOffset, int *end
const QFont charFormatFont = charFormat.font();

AttributeFormatter attrs;
QString family = charFormatFont.families().first();
QString family = charFormatFont.families().value(0, QString());
if (!family.isEmpty()) {
family = family.replace(u'\\', QLatin1String("\\\\"));
family = family.replace(u':', QLatin1String("\\:"));
Expand Down

0 comments on commit 420e27c

Please sign in to comment.