]> git.neil.brown.name Git - edlib.git/commitdiff
lib-glibevents: catch errors from callbacks.
authorNeilBrown <neil@brown.name>
Wed, 28 Jun 2023 21:00:45 +0000 (07:00 +1000)
committerNeilBrown <neil@brown.name>
Wed, 28 Jun 2023 21:03:47 +0000 (07:03 +1000)
The on-idle and poll callbacks didn't catch errors, would cause be
fatal.

Also change on-idle callbacks to not return errors, on Efalse.

Signed-off-by: NeilBrown <neil@brown.name>
lib-autosave.c
python/lib-autospell.py
python/lib-glibevents.py

index bdf0132bbe24d4001e37a7de2360993fdb34c4ec..eaef0a9e0f6fb5b4e1f164bffc726b4590ee2652 100644 (file)
@@ -196,11 +196,11 @@ DEF_CMD(ask_autosave)
        call_comm("editor:notify:all-displays", p, &cr.c);
        if (!cr.p)
                /* No display!!! */
-               return Efail;
+               return Efalse;
 
        p2 = call_ret(pane, "PopupTile", pane_leaf(cr.p), 0, NULL, "DM3sta");
        if (!p2)
-               return Efail;
+               return Efalse;
 
        if ((s = pane_attr_get(p, "autosave-exists")) != NULL &&
            strcmp(s, "yes") == 0) {
@@ -216,7 +216,7 @@ DEF_CMD(ask_autosave)
 
        if (!a || !f) {
                call("popup:close", p2);
-               return Efail;
+               return Efalse;
        }
        doc = call_ret(pane, "doc:from-text", p,
                       0, NULL, "*Autosave-Diff*",
index 4d7dce16c6739f3df67726f1e72acfbd810fa327..6161862e458cdc51f472551dcbaf2e9492c983cd 100644 (file)
@@ -273,7 +273,7 @@ class autospell_view(edlib.Pane):
         self.call("doc:notify:spell:choose-range", start, end)
         if start >= end:
             # nothing to do
-            return edlib.Efail
+            return edlib.Efalse
 
         self.set_time()
         focus = focus.leaf
@@ -304,7 +304,7 @@ class autospell_view(edlib.Pane):
                 remain = -1
         if remain >= 0:
             self.sched()
-        return edlib.Efail
+        return edlib.Efalse
 
 def autospell_attach(key, focus, comm2, **a):
     p = autospell_view(focus)
index 3c31107e4c16dd29a11ba61a461134dbc0d7594a..03e47f7e47f2eaf01f9f62b2c38712ea2db07d33 100644 (file)
@@ -132,7 +132,11 @@ class events(edlib.Pane):
         while self.idle_list[prio]:
             s = self.idle_list[prio].pop()
             f,c,e,n = self.events[s]
-            if c("callback:on-idle", f, n) > 0:
+            try:
+                ret = c("callback:on-idle", f, n)
+            except edlib.commandfailed:
+                ret = edlib.Efalse
+            if ret > 0:
                 if just_one:
                     return
 
@@ -142,7 +146,11 @@ class events(edlib.Pane):
             self.dont_block = False
             for s in self.poll_list:
                 f,c,e,n = self.events[s]
-                if c("callback:poll", f, n) > 0:
+                try:
+                    ret = c("callback:poll", f, n)
+                except edlib.commandfailed:
+                    ret = edlib.Efalse
+                if ret > 0:
                     dont_block = True
             if not dont_block:
                 # Disable any alarm set by python (or other interpreter)