|
fltk 1.3.0rc3
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X. Release candidate.
SfR Fresh Dox: fltk-1.3.0rc3-source.tar.gz ("inofficial" and yet experimental doxygen-generated source code documentation) ![]() |
#include <Fl.H>
Public Member Functions | |
| Fl_Widget_Tracker (Fl_Widget *wi) | |
| ~Fl_Widget_Tracker () | |
| Fl_Widget * | widget () |
| int | deleted () |
| int | exists () |
This class should be used to control safe widget deletion.
You can use an Fl_Widget_Tracker object to watch another widget, if you need to know, if this widget has been deleted during a callback.
This simplifies the use of the "safe widget deletion" methods Fl::watch_widget_pointer() and Fl::release_widget_pointer() and makes their use more reliable, because the destructor autmatically releases the widget pointer from the widget watch list.
It is intended to be used as an automatic (local/stack) variable, such that the automatic destructor is called when the object's scope is left. This ensures that no stale widget pointers are left in the widget watch list (see example below).
You can also create Fl_Widget_Tracker objects with new, but then it is your responsibility to delete the object (and thus remove the widget pointer from the watch list) when it is not needed any more.
Example:
int MyClass::handle (int event) { if (...) { Fl_Widget_Tracker wp(this); // watch myself do_callback(); // call the callback if (wp.deleted()) return 1; // exit, if deleted // Now we are sure that the widget has not been deleted. // It is safe to access the widget clear_changed(); // access the widget } }
| Fl_Widget_Tracker::Fl_Widget_Tracker | ( | Fl_Widget * | wi | ) |
The constructor adds a widget to the watch list.
Definition at line 1840 of file Fl.cxx.
References Fl::watch_widget_pointer().
| Fl_Widget_Tracker::~Fl_Widget_Tracker | ( | ) |
The destructor removes a widget from the watch list.
Definition at line 1849 of file Fl.cxx.
References Fl::release_widget_pointer().
| int Fl_Widget_Tracker::deleted | ( | ) | [inline] |
Returns 1, if the watched widget has been deleted.
This is a convenience method. You can also use something like
if (wp.widget() == 0) // ...
where wp is an Fl_Widget_Tracker object.
Definition at line 1136 of file Fl.H.
Referenced by Fl_Widget::do_callback(), Fl_Tabs::handle(), Fl_Slider::handle(), Fl_Dial::handle(), Fl_Counter::handle(), Fl_Button::handle(), Fl_Browser_::handle(), Fl_Adjuster::handle(), and Fl_Browser_::select_only().
| int Fl_Widget_Tracker::exists | ( | ) | [inline] |
Returns 1, if the watched widget exists (has not been deleted).
This is a convenience method. You can also use something like
if (wp.widget() != 0) // ...
where wp is an Fl_Widget_Tracker object.
Definition at line 1147 of file Fl.H.
Referenced by Fl_Value_Input::handle(), Fl_Group::handle(), Fl_File_Input::handle(), and Fl_Menu_Button::popup().
| Fl_Widget* Fl_Widget_Tracker::widget | ( | ) | [inline] |
Returns a pointer to the watched widget.
This pointer is NULL, if the widget has been deleted.
Definition at line 1125 of file Fl.H.
Referenced by Fl_Button::key_release_timeout().