File 079-baseclass-Avoid-glib-Source-ID-XX-not-found-at-app-shutdown.patch of Package virt-manager

Subject: baseclass: Avoid glib `Source ID XX not found` at app shutdown
From: Cole Robinson crobinso@redhat.com Sun Mar 3 11:54:11 2024 -0500
Date: Sun Mar 3 14:18:04 2024 -0500:
Git: 75e4d1dd294f26f1f17625fe075c6a6fe2c0f8b4

Signed-off-by: Cole Robinson <crobinso@redhat.com>

diff --git a/virtManager/baseclass.py b/virtManager/baseclass.py
index cd3df8ef..2a475a33 100644
--- a/virtManager/baseclass.py
+++ b/virtManager/baseclass.py
@@ -164,8 +164,20 @@ class vmmGObject(GObject.GObject):
         GLib timeout_add wrapper to simplify callers, and track handles
         for easy cleanup
         """
-        ret = GLib.timeout_add(timeout, func, *args)
+        id_list = []
+        def wrap_func(*wrapargs):
+            # When the our timeout_add callback returns False, remove
+            # the source ID from our cache, to avoid glib warnings like
+            # this at app shutdown:
+            # Warning: Source ID 60 was not found when attempting to remove it
+            func_ret = func(*wrapargs)
+            if not func_ret:
+                self.remove_gobject_timeout(id_list[0])
+            return func_ret
+
+        ret = GLib.timeout_add(timeout, wrap_func, *args)
         self.add_gobject_timeout(ret)
+        id_list.append(ret)
         return ret
 
     def emit(self, signal_name, *args):
openSUSE Build Service is sponsored by