# HG changeset patch # User John W. Eaton # Date 1469736431 14400 # Node ID e68128601f5e5328c25f8bc4f376b679e038cca8 # Parent 829e0aafebdc051e533a66fcf231d9690a4e258e 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. diff -r 829e0aafebdc -r e68128601f5e libgui/graphics/Container.cc --- 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 () - ->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 () + ->setGeometry (octave::math::round (bb(0)), octave::math::round (bb(1)), + octave::math::round (bb(2)), octave::math::round (bb(3))); + } } } } diff -r 829e0aafebdc -r e68128601f5e libgui/graphics/Panel.cc --- 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; diff -r 829e0aafebdc -r e68128601f5e libinterp/corefcn/graphics.in.h --- 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);