fix(libsearch):解决加载svg(绝对路径的图片)图标失败的问题

This commit is contained in:
iaom 2024-02-23 15:17:56 +08:00
parent a4170b98be
commit 583f94eb1f
1 changed files with 9 additions and 0 deletions

View File

@ -22,12 +22,21 @@
#include <QMutex> #include <QMutex>
#include <QMutexLocker> #include <QMutexLocker>
#include <XdgIcon> #include <XdgIcon>
#include <QFile>
namespace UkuiSearch { namespace UkuiSearch {
static QMutex qtIconMutex; static QMutex qtIconMutex;
static QMutex xdgIconMutex; static QMutex xdgIconMutex;
QIcon IconLoader::loadIconQt(const QString &name, const QIcon &fallback) QIcon IconLoader::loadIconQt(const QString &name, const QIcon &fallback)
{ {
QMutexLocker locker(&qtIconMutex); QMutexLocker locker(&qtIconMutex);
if(QFile::exists(name)) {
QIcon icon(name);
if(!QIcon(name).isNull()) {
return icon;
} else {
return fallback;
}
}
return QIcon::fromTheme(name,fallback); return QIcon::fromTheme(name,fallback);
} }