Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GTK text buffer spam #43

Open
heuristicus opened this issue May 19, 2023 · 0 comments
Open

GTK text buffer spam #43

heuristicus opened this issue May 19, 2023 · 0 comments

Comments

@heuristicus
Copy link

heuristicus commented May 19, 2023

After a short time running, procman will start to spam

(sheriff:214359): Gtk-CRITICAL **: 13:39:13.700: gtk_text_buffer_delete: assertion 'gtk_text_iter_get_buffer (start) == buffer' failed

I think this is caused by the idle add command here. Likely because when the idle add actually calls the function, the buffer has moved so the iterators are no longer valid.

if num_lines > self.stdout_maxlines:
start_iter = tb.get_start_iter()
chop_iter = tb.get_iter_at_line(num_lines - self.stdout_maxlines)
# Must use idle_add here otherwise the output console will not be updated correctly
GLib.idle_add(functools.partial(self.del_tb, start_iter, chop_iter))

I tried creating a function that would get the text buffer values after it is called, but somehow this didn't fix the issue.

index ce6bf9d..7e92a7a 100644
--- a/python/src/procman_ros/sheriff_gtk/command_console.py
+++ b/python/src/procman_ros/sheriff_gtk/command_console.py
@@ -201,10 +201,15 @@ class SheriffCommandConsole(Gtk.ScrolledWindow, SheriffListener):
         # toss out old text if the buffer is getting too big
         num_lines = tb.get_line_count()
         if num_lines > self.stdout_maxlines:
-            start_iter = tb.get_start_iter()
-            chop_iter = tb.get_iter_at_line(num_lines - self.stdout_maxlines)
             # Must use idle_add here otherwise the output console will not be updated correctly
+            GLib.idle_add(functools.partial(self.idle_del_tb, tb))
+
+    def idle_del_tb(self, tb):
+        num_lines = tb.get_line_count()
+        start_iter = tb.get_start_iter()
+        chop_iter = tb.get_iter_at_line(num_lines - self.stdout_maxlines)
+        self.del_tb(start_iter, chop_iter)
 
     def del_tb(self, start, chop):
         self.sheriff_tb.delete(start, chop)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant