FLTK 1.3.8
|
This class should be used to control safe widget deletion. More...
#include <Fl.H>
Public Member Functions | |
int | deleted () |
Returns 1, if the watched widget has been deleted. More... | |
int | exists () |
Returns 1, if the watched widget exists (has not been deleted). More... | |
Fl_Widget_Tracker (Fl_Widget *wi) | |
The constructor adds a widget to the watch list. | |
Fl_Widget * | widget () |
Returns a pointer to the watched widget. More... | |
~Fl_Widget_Tracker () | |
The destructor removes a widget from the watch list. | |
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:
|
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.
|
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.
|
inline |
Returns a pointer to the watched widget.
This pointer is NULL
, if the widget has been deleted.