summaryrefslogtreecommitdiffstats
path: root/swaybar/tray/tray.c
diff options
context:
space:
mode:
Diffstat (limited to 'swaybar/tray/tray.c')
-rw-r--r--swaybar/tray/tray.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/swaybar/tray/tray.c b/swaybar/tray/tray.c
index 00f1a44f..91c3af06 100644
--- a/swaybar/tray/tray.c
+++ b/swaybar/tray/tray.c
@@ -1,4 +1,4 @@
1#define _XOPEN_SOURCE 500 1#define _XOPEN_SOURCE 700
2#include <unistd.h> 2#include <unistd.h>
3#include <stdlib.h> 3#include <stdlib.h>
4#include <string.h> 4#include <string.h>
@@ -90,13 +90,16 @@ static void get_items_reply(DBusPendingCall *pending, void *_data) {
90 90
91 struct StatusNotifierItem *item = sni_create(name); 91 struct StatusNotifierItem *item = sni_create(name);
92 92
93 sway_log(L_DEBUG, "Item registered with host: %s", name); 93 if (item) {
94 list_add(tray->items, item); 94 sway_log(L_DEBUG, "Item registered with host: %s", name);
95 dirty = true; 95 list_add(tray->items, item);
96 dirty = true;
97 }
96 } 98 }
97 99
98bail: 100bail:
99 dbus_message_unref(reply); 101 dbus_message_unref(reply);
102 dbus_pending_call_unref(pending);
100 return; 103 return;
101} 104}
102static void get_items() { 105static void get_items() {
@@ -141,8 +144,10 @@ static DBusHandlerResult signal_handler(DBusConnection *connection,
141 if (list_seq_find(tray->items, sni_str_cmp, name) == -1) { 144 if (list_seq_find(tray->items, sni_str_cmp, name) == -1) {
142 struct StatusNotifierItem *item = sni_create(name); 145 struct StatusNotifierItem *item = sni_create(name);
143 146
144 list_add(tray->items, item); 147 if (item) {
145 dirty = true; 148 list_add(tray->items, item);
149 dirty = true;
150 }
146 } 151 }
147 152
148 return DBUS_HANDLER_RESULT_HANDLED; 153 return DBUS_HANDLER_RESULT_HANDLED;