changeset 22190:e68128601f5e

skip invalid objects in Qt graphics event handlers (bug #46501) * Container.cc (Container::resizeEvent): Avoid accessing properties from invalid graphics object. * Panel.cc (Panel::eventFilter): Likewise. * graphics.in.h (base_graphics_object:get_properties): Issue warning instead of error.
author John W. Eaton <jwe@octave.org>
date Thu, 28 Jul 2016 16:07:11 -0400
parents 829e0aafebdc
children 8971508e21c8
files libgui/graphics/Container.cc libgui/graphics/Panel.cc libinterp/corefcn/graphics.in.h
diffstat 3 files changed, 22 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/graphics/Container.cc	Thu Jul 28 16:54:54 2016 +0200
+++ b/libgui/graphics/Container.cc	Thu Jul 28 16:07:11 2016 -0400
@@ -89,11 +89,16 @@
 
           if (obj)
             {
-              Matrix bb = obj->properties ().get_boundingbox (false);
+              graphics_object go = obj->object ();
 
-              obj->qWidget<QWidget> ()
-                ->setGeometry (octave::math::round (bb(0)), octave::math::round (bb(1)),
-                               octave::math::round (bb(2)), octave::math::round (bb(3)));
+              if (go.valid_object ())
+                {
+                  Matrix bb = go.get_properties ().get_boundingbox (false);
+
+                  obj->qWidget<QWidget> ()
+                    ->setGeometry (octave::math::round (bb(0)), octave::math::round (bb(1)),
+                                   octave::math::round (bb(2)), octave::math::round (bb(3)));
+                }
             }
         }
     }
--- a/libgui/graphics/Panel.cc	Thu Jul 28 16:54:54 2016 +0200
+++ b/libgui/graphics/Panel.cc	Thu Jul 28 16:07:11 2016 -0400
@@ -191,7 +191,11 @@
                     {
                       gh_manager::auto_lock lock;
 
-                      ContextMenu::executeAt (properties (), m->globalPos ());
+                      graphics_object go = object ();
+
+                      if (go.valid_object ())
+                        ContextMenu::executeAt (go.get_properties (),
+                                                m->globalPos ());
                     }
                 }
               break;
@@ -209,7 +213,10 @@
                 {
                   gh_manager::auto_lock lock;
 
-                  properties ().update_boundingbox ();
+                  graphics_object go = object ();
+
+                  if (go.valid_object ())
+                    go.get_properties ().update_boundingbox ();
                 }
               break;
 
--- a/libinterp/corefcn/graphics.in.h	Thu Jul 28 16:54:54 2016 +0200
+++ b/libinterp/corefcn/graphics.in.h	Thu Jul 28 16:07:11 2016 -0400
@@ -2796,13 +2796,15 @@
   virtual base_properties& get_properties (void)
   {
     static base_properties properties;
-    error ("base_graphics_object::get_properties: invalid graphics object");
+    warning ("base_graphics_object::get_properties: invalid graphics object");
+    return properties;
   }
 
   virtual const base_properties& get_properties (void) const
   {
     static base_properties properties;
-    error ("base_graphics_object::get_properties: invalid graphics object");
+    warning ("base_graphics_object::get_properties: invalid graphics object");
+    return properties;
   }
 
   virtual void update_axis_limits (const std::string& axis_type);