# HG changeset patch # User John W. Eaton # Date 1292834797 18000 # Node ID e5f3d1822e4b5a73f705b08d4d60f2d032da2bc9 # Parent 57868a21170e8875e6d9a5b800214d7f6153f3d9 avoid crash with invisible FLTK plots diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2010-12-20 John W. Eaton + + * graphics.cc (graphics_handle::is_visible): New function. + * graphics.h.in: Provide decl. + * DLD-FUNCTIONS/fltk_backend.cc (figure_manager::do_update_canvas): + Don't show canvas if it is invisible. + 2012-12-17 Konstantinos Poulios * graphics.h.in (class axes::properties): Tag xtickmode, ytickmode diff --git a/src/DLD-FUNCTIONS/fltk_backend.cc b/src/DLD-FUNCTIONS/fltk_backend.cc --- a/src/DLD-FUNCTIONS/fltk_backend.cc +++ b/src/DLD-FUNCTIONS/fltk_backend.cc @@ -1630,12 +1630,12 @@ } } - void do_update_canvas (int idx, graphics_handle ca) + void do_update_canvas (int idx, graphics_handle gh) { wm_iterator win; if ((win = windows.find (idx)) != windows.end ()) { - if (ca.ok ()) + if (gh.is_visible ()) win->second->show_canvas (); else win->second->hide_canvas (); diff --git a/src/graphics.cc b/src/graphics.cc --- a/src/graphics.cc +++ b/src/graphics.cc @@ -759,6 +759,34 @@ // --------------------------------------------------------------------- +// An object is visible if its "visible" property is "on" and all its +// parents are also visible. + +bool +graphics_handle::is_visible (void) const +{ + if (ok ()) + { + graphics_object go = gh_manager::get_object (*this); + + if (go) + { + base_properties& go_props = go.get_properties (); + + if (go_props.is_visible ()) + { + graphics_handle gh = go.get_parent (); + + return gh.ok () ? gh.is_visible () : true; + } + else + return false; + } + } + + return false; +} + bool base_property::set (const octave_value& v, bool do_run ) { diff --git a/src/graphics.h.in b/src/graphics.h.in --- a/src/graphics.h.in +++ b/src/graphics.h.in @@ -110,6 +110,8 @@ bool ok (void) const { return ! xisnan (val); } + bool is_visible (void) const; + private: double val; };