summaryrefslogtreecommitdiff
path: root/src/Fl_Slider.cxx
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2010-02-20 17:40:07 +0000
committerAlbrecht Schlosser <albrechts.fltk@online.de>2010-02-20 17:40:07 +0000
commit7ae0c170ad2f63ac7e27d0496cd9c167e2bd0cbd (patch)
tree0d51f2e36cc11714c6ee5923f8d52c6a9a3793dc /src/Fl_Slider.cxx
parentc7a1aead4c9b79882b64267b492b1f9d87ab22d0 (diff)
Added Fl_Widget_Tracker in handle() methods etc. to avoid accessing widgets
after deletion (STR #1306). This is all I could find, but maybe there are more places in the code. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7115 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Slider.cxx')
-rw-r--r--src/Fl_Slider.cxx72
1 files changed, 43 insertions, 29 deletions
diff --git a/src/Fl_Slider.cxx b/src/Fl_Slider.cxx
index 93a4457fd..6b2a328d1 100644
--- a/src/Fl_Slider.cxx
+++ b/src/Fl_Slider.cxx
@@ -222,10 +222,14 @@ void Fl_Slider::draw() {
}
int Fl_Slider::handle(int event, int X, int Y, int W, int H) {
+ // Fl_Widget_Tracker wp(this);
switch (event) {
- case FL_PUSH:
+ case FL_PUSH: {
+ Fl_Widget_Tracker wp(this);
if (!Fl::event_inside(X, Y, W, H)) return 0;
handle_push();
+ if (wp.deleted()) return 1; }
+ // fall through ...
case FL_DRAG: {
double val;
@@ -293,34 +297,44 @@ int Fl_Slider::handle(int event, int X, int Y, int W, int H) {
case FL_RELEASE:
handle_release();
return 1;
- case FL_KEYBOARD :
- switch (Fl::event_key()) {
- case FL_Up:
- if (horizontal()) return 0;
- handle_push();
- handle_drag(clamp(increment(value(),-1)));
- handle_release();
- return 1;
- case FL_Down:
- if (horizontal()) return 0;
- handle_push();
- handle_drag(clamp(increment(value(),1)));
- handle_release();
- return 1;
- case FL_Left:
- if (!horizontal()) return 0;
- handle_push();
- handle_drag(clamp(increment(value(),-1)));
- handle_release();
- return 1;
- case FL_Right:
- if (!horizontal()) return 0;
- handle_push();
- handle_drag(clamp(increment(value(),1)));
- handle_release();
- return 1;
- default:
- return 0;
+ case FL_KEYBOARD:
+ { Fl_Widget_Tracker wp(this);
+ switch (Fl::event_key()) {
+ case FL_Up:
+ if (horizontal()) return 0;
+ handle_push();
+ if (wp.deleted()) return 1;
+ handle_drag(clamp(increment(value(),-1)));
+ if (wp.deleted()) return 1;
+ handle_release();
+ return 1;
+ case FL_Down:
+ if (horizontal()) return 0;
+ handle_push();
+ if (wp.deleted()) return 1;
+ handle_drag(clamp(increment(value(),1)));
+ if (wp.deleted()) return 1;
+ handle_release();
+ return 1;
+ case FL_Left:
+ if (!horizontal()) return 0;
+ handle_push();
+ if (wp.deleted()) return 1;
+ handle_drag(clamp(increment(value(),-1)));
+ if (wp.deleted()) return 1;
+ handle_release();
+ return 1;
+ case FL_Right:
+ if (!horizontal()) return 0;
+ handle_push();
+ if (wp.deleted()) return 1;
+ handle_drag(clamp(increment(value(),1)));
+ if (wp.deleted()) return 1;
+ handle_release();
+ return 1;
+ default:
+ return 0;
+ }
}
// break not required because of switch...
case FL_FOCUS :