From 9f1eeaee19576584fab930b6d407d0c5b307dacb Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Sun, 8 Feb 2009 14:44:15 +0000 Subject: Added the helper class Fl_Watch to simplify safe handling of widget deletion in callbacks. This is used e.g. in Fl_Widget::do_callback() to prevent accessing widgets after deletion in the callback. Documentation adjusted, Fl_Menu_Button.cxx changed to use Fl_Watch instead of Fl::watch_widget_pointer. Fl::watch_widget_pointer() and Fl::release_widget_pointer() have been modified to use an array without "holes" (NULL pointers) for storing the widget pointers for faster access: Fl::release_widget_pointer() now shifts pointers to close gaps of freed pointers. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6651 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_Widget.cxx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/Fl_Widget.cxx') diff --git a/src/Fl_Widget.cxx b/src/Fl_Widget.cxx index 550f1eb1c..740dad6fd 100644 --- a/src/Fl_Widget.cxx +++ b/src/Fl_Widget.cxx @@ -293,6 +293,21 @@ Fl_Widget::copy_label(const char *a) { redraw_label(); } +/** Calls the widget callback. + + Causes a widget to invoke its callback function with arbitrary arguments. + \param[in] o call the callback with \a o as the widget argument + \param[in] arg call the callback with \a arg as the user data argument + \see callback() +*/ +void +Fl_Widget::do_callback(Fl_Widget* o,void* arg) { + Fl_Watch wp(o); + callback_(o,arg); + if (wp.deleted()) return; + if (callback_ != default_callback) + clear_changed(); +} // // End of "$Id$". -- cgit v1.2.3