changeset 24524:a56d283ff18a

Honor "interruptible" for property listeners (bug #52804). * NEWS: Announce "interruptible" property is fully implemented. * graphics.cc (gh_manager::do_execute_listener): If the currently executing callback is not interruptible, queue or cancel listeners.
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Thu, 04 Jan 2018 15:38:46 +0100
parents 501986e12b8b
children a8eb8a734b9d
files NEWS libinterp/corefcn/graphics.cc
diffstat 2 files changed, 20 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Wed Jan 03 21:21:41 2018 +0100
+++ b/NEWS	Thu Jan 04 15:38:46 2018 +0100
@@ -63,8 +63,12 @@
     explicitly instructed to perform an economy factorization by using a
     final argument of 0.
 
- ** The graphic object property "PickableParts" has been implemented which
-    controls whether an object can accept mouse clicks.
+ ** The graphic object property "PickableParts" has been implemented
+    which controls whether an object can accept mouse clicks.
+
+ ** The graphic object property "Interruptible" has been fully
+    implemented which controls whether a running callback function can
+    be interrupted by another callback function. 
 
  ** Text objects now implement the properties "BackgroundColor",
     "EdgeColor", "LineStyle", "LineWidth", and "Margin".
--- a/libinterp/corefcn/graphics.cc	Wed Jan 03 21:21:41 2018 +0100
+++ b/libinterp/corefcn/graphics.cc	Thu Jan 04 15:38:46 2018 +0100
@@ -10223,6 +10223,20 @@
 gh_manager::do_execute_listener (const graphics_handle& h,
                                  const octave_value& l)
 {
+  if (! callback_objects.empty ())
+    {        
+      const graphics_object& current = callback_objects.front ();
+
+      if (current.valid_object () 
+          && ! current.get_properties ().is_interruptible ())
+        {
+          if (get_object (h).get_properties ().busyaction_is ("queue"))
+            do_post_event (graphics_event::create_callback_event (h, l));
+
+          return;
+        }
+    }
+
   if (octave::thread::is_thread ())
     gh_manager::execute_callback (h, l, octave_value ());
   else