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

This commit is contained in:
iaom 2024-02-23 15:17:56 +08:00
parent 7d36be89d9
commit cf9e768b4b
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);
} }