Skip to content

Commit 902b1ef

Browse files
committed
Prevent GLib warnings when removing tray icon sources
Adds a check to ensure a GSource exists before calling g_source_remove in TrayIcon::Impl destructor. This avoids potential GLib warnings when cleaning up pending sources.
1 parent 99c6247 commit 902b1ef

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/platform/linux/tray_icon_linux.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,14 @@ class TrayIcon::Impl {
3939

4040
~Impl() {
4141
// Cancel any pending cleanup timeouts
42+
// Check if source exists before removing to avoid GLib warnings
43+
GMainContext* context = g_main_context_default();
4244
for (guint source_id : pending_cleanup_sources_) {
4345
if (source_id > 0) {
44-
g_source_remove(source_id);
46+
GSource* source = g_main_context_find_source_by_id(context, source_id);
47+
if (source) {
48+
g_source_remove(source_id);
49+
}
4550
}
4651
}
4752
pending_cleanup_sources_.clear();

0 commit comments

Comments
 (0)