QDBusTrayIcon: Avoid needless initialization of a global var
TempFileTemplate is initialized each time an application starts. It leads to the call of QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation) which is slow and can even change permissions of the runtime directory. Use a static wrapper function to initialize this variable only when needed. Change-Id: Ib620f9b842c88103c67f8dfab200f4d39c9981ee Reviewed-by: Dmitry Shachnev <mitya57@gmail.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>bb10
parent
c4928e99e9
commit
d640dbf730
|
|
@ -90,12 +90,17 @@ static QString iconTempPath()
|
|||
|
||||
static const QString KDEItemFormat = QStringLiteral("org.kde.StatusNotifierItem-%1-%2");
|
||||
static const QString KDEWatcherService = QStringLiteral("org.kde.StatusNotifierWatcher");
|
||||
static const QString TempFileTemplate = iconTempPath() + QLatin1String("/qt-trayicon-XXXXXX.png");
|
||||
static const QString XdgNotificationService = QStringLiteral("org.freedesktop.Notifications");
|
||||
static const QString XdgNotificationPath = QStringLiteral("/org/freedesktop/Notifications");
|
||||
static const QString DefaultAction = QStringLiteral("default");
|
||||
static int instanceCount = 0;
|
||||
|
||||
static inline QString tempFileTemplate()
|
||||
{
|
||||
static const QString TempFileTemplate = iconTempPath() + QLatin1String("/qt-trayicon-XXXXXX.png");
|
||||
return TempFileTemplate;
|
||||
}
|
||||
|
||||
/*!
|
||||
\class QDBusTrayIcon
|
||||
\internal
|
||||
|
|
@ -206,7 +211,7 @@ QTemporaryFile *QDBusTrayIcon::tempIcon(const QIcon &icon)
|
|||
if (!necessary)
|
||||
return nullptr;
|
||||
qreal dpr = qGuiApp->devicePixelRatio();
|
||||
QTemporaryFile *ret = new QTemporaryFile(TempFileTemplate, this);
|
||||
QTemporaryFile *ret = new QTemporaryFile(tempFileTemplate(), this);
|
||||
ret->open();
|
||||
icon.pixmap(QSize(22 * dpr, 22 * dpr)).save(ret);
|
||||
ret->close();
|
||||
|
|
|
|||
Loading…
Reference in New Issue