summaryrefslogtreecommitdiff
path: root/src/Fl_Scroll.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/Fl_Scroll.cxx')
-rw-r--r--src/Fl_Scroll.cxx17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/Fl_Scroll.cxx b/src/Fl_Scroll.cxx
index 085d47bf0..333c4892d 100644
--- a/src/Fl_Scroll.cxx
+++ b/src/Fl_Scroll.cxx
@@ -32,13 +32,16 @@
/** Clear all but the scrollbars... */
void Fl_Scroll::clear() {
- for (int i=children() - 1; i >= 0; i --) {
- Fl_Widget* o = child(i);
- if (o != &hscrollbar && o != &scrollbar) {
- remove(o);
- delete o;
- }
- }
+ // Note: the scrollbars are removed from the group before
+ // calling Fl_Group::clear() to take advantage of the
+ // optimized widget removal. Finally they are added
+ // to the Fl_Scroll's group again.
+ // This is MUCH faster than removing each widget.
+ remove(scrollbar);
+ remove(hscrollbar);
+ Fl_Group::clear();
+ add(hscrollbar);
+ add(scrollbar);
}
/** Insure the scrollbars are the last children */