From 0b5eb47b373ee1784989ef67fbb39eb8d1ba819e Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sun, 15 Mar 2020 00:12:57 +0400 Subject: [PATCH] Avoid usage of QDBusInterface in StatusNotifierItem to avoid crashes --- .../statusnotifieritem/statusnotifieritem.cpp | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/Telegram/ThirdParty/statusnotifieritem/statusnotifieritem.cpp b/Telegram/ThirdParty/statusnotifieritem/statusnotifieritem.cpp index a55079740c..38f0eea1cc 100644 --- a/Telegram/ThirdParty/statusnotifieritem/statusnotifieritem.cpp +++ b/Telegram/ThirdParty/statusnotifieritem/statusnotifieritem.cpp @@ -27,8 +27,8 @@ #include "statusnotifieritem.h" #include "statusnotifieritemadaptor.h" -#include #include +#include #include int StatusNotifierItem::mServiceCounter = 0; @@ -75,11 +75,16 @@ StatusNotifierItem::~StatusNotifierItem() void StatusNotifierItem::registerToHost() { - QDBusInterface interface(QLatin1String("org.kde.StatusNotifierWatcher"), - QLatin1String("/StatusNotifierWatcher"), - QLatin1String("org.kde.StatusNotifierWatcher"), - mSessionBus); - interface.asyncCall(QLatin1String("RegisterStatusNotifierItem"), mSessionBus.baseService()); + QDBusMessage message = QDBusMessage::createMethodCall(QLatin1String("org.kde.StatusNotifierWatcher"), + QLatin1String("/StatusNotifierWatcher"), + QLatin1String("org.kde.StatusNotifierWatcher"), + QLatin1String("RegisterStatusNotifierItem")); + + message.setArguments({ + mSessionBus.baseService() + }); + + mSessionBus.send(message); } void StatusNotifierItem::onServiceOwnerChanged(const QString& service, const QString& oldOwner, @@ -292,10 +297,23 @@ void StatusNotifierItem::Scroll(int delta, const QString &orientation) void StatusNotifierItem::showMessage(const QString& title, const QString& msg, const QString& iconName, int secs) { - QDBusInterface interface(QLatin1String("org.freedesktop.Notifications"), QLatin1String("/org/freedesktop/Notifications"), - QLatin1String("org.freedesktop.Notifications"), mSessionBus); - interface.call(QLatin1String("Notify"), mTitle, (uint) 0, iconName, title, - msg, QStringList(), QVariantMap(), secs); + QDBusMessage message = QDBusMessage::createMethodCall(QLatin1String("org.freedesktop.Notifications"), + QLatin1String("/org/freedesktop/Notifications"), + QLatin1String("org.freedesktop.Notifications"), + QLatin1String("Notify")); + + message.setArguments({ + mTitle, + (uint) 0, + iconName, + title, + msg, + QStringList(), + QVariantMap(), + secs + }); + + mSessionBus.send(message); } IconPixmapList StatusNotifierItem::iconToPixmapList(const QIcon& icon)