31
31
#ifdef USE_DBUS
32
32
// https://wiki.ubuntu.com/NotificationDevelopmentGuidelines recommends at least 128
33
33
const int FREEDESKTOP_NOTIFICATION_ICON_SIZE = 128 ;
34
+
35
+ void DBusInitThread::run () {
36
+ auto interface = new QDBusInterface (" org.freedesktop.Notifications" , " /org/freedesktop/Notifications" , " org.freedesktop.Notifications" );
37
+ if (!interface->isValid ()) {
38
+ delete interface;
39
+ return ;
40
+ }
41
+ interface->moveToThread (m_notificator.thread ());
42
+ m_notificator.interface = interface;
43
+ m_notificator.mode = Notificator::Freedesktop;
44
+ }
45
+
34
46
#endif
35
47
36
48
Notificator::Notificator (const QString &programName, QSystemTrayIcon *trayicon, QWidget *parent) :
@@ -48,12 +60,8 @@ Notificator::Notificator(const QString &programName, QSystemTrayIcon *trayicon,
48
60
mode = QSystemTray;
49
61
}
50
62
#ifdef USE_DBUS
51
- interface = new QDBusInterface (" org.freedesktop.Notifications" ,
52
- " /org/freedesktop/Notifications" , " org.freedesktop.Notifications" );
53
- if (interface->isValid ())
54
- {
55
- mode = Freedesktop;
56
- }
63
+ m_dbus_init_thread = new DBusInitThread (*this );
64
+ m_dbus_init_thread->start ();
57
65
#endif
58
66
#ifdef Q_OS_MAC
59
67
// check if users OS has support for NSUserNotification
@@ -82,6 +90,8 @@ Notificator::Notificator(const QString &programName, QSystemTrayIcon *trayicon,
82
90
Notificator::~Notificator ()
83
91
{
84
92
#ifdef USE_DBUS
93
+ m_dbus_init_thread->wait ();
94
+ delete m_dbus_init_thread;
85
95
delete interface;
86
96
#endif
87
97
}
0 commit comments