Skip to content

Commit

Permalink
perf: [desktop-fileinfo] The cpu usage is high when the mouse clicks …
Browse files Browse the repository at this point in the history
…the desktop icon

1. When the icon of a desktop file is in svg format and the mouse moves over the file,
QIcon is frequently invoked to create an object, resulting in high cpu usage.
2. svg availableSizes returns a null value, causing the cache QIcon to be emptied,
resulting in not only a rebuild, but also a high cpu utilization.
3. Remove the judgment of availableSizes.

Log: fix issue
Bug: https://pms.uniontech.com/bug-view-289327.html
  • Loading branch information
GongHeng2017 committed Nov 28, 2024
1 parent e4e917e commit 62bb487
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/dfm-base/file/local/desktopfileinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,7 @@ QStringList DesktopFileInfo::desktopCategories() const
QIcon DesktopFileInfo::fileIcon()
{
if (Q_LIKELY(!d->icon.isNull())) {
if (Q_LIKELY(!d->icon.availableSizes().isEmpty()))
return d->icon;

d->icon = QIcon();
return d->icon;
}

const QString &iconName = this->nameOf(NameInfoType::kIconName);
Expand Down

0 comments on commit 62bb487

Please sign in to comment.