diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl.cxx | 31 | ||||
| -rw-r--r-- | src/Fl_Menu_Button.cxx | 2 | ||||
| -rw-r--r-- | src/Fl_Widget.cxx | 5 |
3 files changed, 21 insertions, 17 deletions
diff --git a/src/Fl.cxx b/src/Fl.cxx index 0e5a1b251..de2b869e1 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -1519,7 +1519,7 @@ static int max_widget_watch = 0; /** Adds a widget pointer to the widget watch list. - \note Internal use only, please use class Fl_Watch instead. + \note Internal use only, please use class Fl_Widget_Tracker instead. This can be used, if it is possible that a widget might be deleted during a callback or similar function. The widget pointer must be added to the @@ -1556,9 +1556,10 @@ static int max_widget_watch = 0; \see Fl::clear_widget_pointer() An easier and more convenient method to control widget deletion during - callbacks is to use the class Fl_Watch with a local (automatic) variable. + callbacks is to use the class Fl_Widget_Tracker with a local (automatic) + variable. - \see class Fl_Watch + \see class Fl_Widget_Tracker */ void Fl::watch_widget_pointer(Fl_Widget *&w) { @@ -1585,7 +1586,7 @@ void Fl::watch_widget_pointer(Fl_Widget *&w) This is used to remove a widget pointer that has been added to the watch list with Fl::watch_widget_pointer(), when it is not needed anymore. - \note Internal use only, please use class Fl_Watch instead. + \note Internal use only, please use class Fl_Widget_Tracker instead. \see Fl::watch_widget_pointer() */ @@ -1617,14 +1618,16 @@ void Fl::release_widget_pointer(Fl_Widget *&w) This is called when a widget is destroyed (by its destructor). You should never call this directly. - - \note Internal use only, please use class Fl_Watch instead. - - This method searches the widget watch list for pointers to the widget and clears - all pointers that point to it. Widget pointers can be added to the widget - watch list by calling Fl::watch_widget_pointer(). - + + \note Internal use only ! + + This method searches the widget watch list for pointers to the widget and + clears each pointer that points to it. Widget pointers can be added to the + widget watch list by calling Fl::watch_widget_pointer() or by using the + helper class Fl_Widget_Tracker (recommended). + \see Fl::watch_widget_pointer() + \see class Fl_Widget_Tracker */ void Fl::clear_widget_pointer(Fl_Widget const *w) { @@ -1637,12 +1640,12 @@ void Fl::clear_widget_pointer(Fl_Widget const *w) } } -// Helper class Fl_Watch +// Helper class Fl_Widget_Tracker /** The constructor adds a widget to the watch list. */ -Fl_Watch::Fl_Watch(Fl_Widget *wi) { +Fl_Widget_Tracker::Fl_Widget_Tracker(Fl_Widget *wi) { wp_ = wi; Fl::watch_widget_pointer(wp_); // add pointer to watch list @@ -1651,7 +1654,7 @@ Fl_Watch::Fl_Watch(Fl_Widget *wi) { /** The destructor removes a widget from the watch list. */ -Fl_Watch::~Fl_Watch() { +Fl_Widget_Tracker::~Fl_Widget_Tracker() { Fl::release_widget_pointer(wp_); // remove pointer from watch list } diff --git a/src/Fl_Menu_Button.cxx b/src/Fl_Menu_Button.cxx index 4c626ee5e..0ae69de51 100644 --- a/src/Fl_Menu_Button.cxx +++ b/src/Fl_Menu_Button.cxx @@ -58,7 +58,7 @@ const Fl_Menu_Item* Fl_Menu_Button::popup() { const Fl_Menu_Item* m; pressed_menu_button_ = this; redraw(); - Fl_Watch mb(this); + Fl_Widget_Tracker mb(this); if (!box() || type()) { m = menu()->popup(Fl::event_x(), Fl::event_y(), label(), mvalue(), this); } else { diff --git a/src/Fl_Widget.cxx b/src/Fl_Widget.cxx index 740dad6fd..e1fa13b79 100644 --- a/src/Fl_Widget.cxx +++ b/src/Fl_Widget.cxx @@ -296,13 +296,14 @@ Fl_Widget::copy_label(const char *a) { /** 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 + \param[in] arg use \a arg as the user data argument \see callback() */ void Fl_Widget::do_callback(Fl_Widget* o,void* arg) { - Fl_Watch wp(o); + Fl_Widget_Tracker wp(o); callback_(o,arg); if (wp.deleted()) return; if (callback_ != default_callback) |
