# HG changeset patch # User Doug Stewart # Date 1326983811 18000 # Node ID 358b59706656396915633d6ede01ee6c89328dfe # Parent 3e94663fc3e92ffcd51ff220b94681b5e5a2e6c8 Stop FLTK plot figure crash with right-mouse zoom (Bug #32592). * __init_fltk__.cc (handle): Limit right mouse button zoom to 4 pixels so that no crash will occur if the zoom box is zero pixels wide. diff -r 3e94663fc3e9 -r 358b59706656 src/DLD-FUNCTIONS/__init_fltk__.cc --- a/src/DLD-FUNCTIONS/__init_fltk__.cc Wed Jan 18 21:27:13 2012 -0800 +++ b/src/DLD-FUNCTIONS/__init_fltk__.cc Thu Jan 19 09:36:51 2012 -0500 @@ -1390,31 +1390,38 @@ axes::properties& ap = dynamic_cast (ax_obj.get_properties ()); pixel2pos (ax_obj, pos_x, pos_y, x0, y0); - pixel2pos (ax_obj, Fl::event_x (), Fl::event_y (), - x1, y1); + int pos_x1 = Fl::event_x (); + int pos_y1 = Fl::event_y (); + pixel2pos (ax_obj, pos_x1, pos_y1, x1, y1); Matrix xl (1,2,0); Matrix yl (1,2,0); - if (x0 < x1) + int dx = abs (pos_x - pos_x1); + int dy = abs (pos_y - pos_y1); + // Smallest zoom box must be 4 pixels square + if ((dx > 4) && (dy > 4)) { - xl(0) = x0; - xl(1) = x1; - } - else - { - xl(0) = x1; - xl(1) = x0; + if (x0 < x1) + { + xl(0) = x0; + xl(1) = x1; + } + else + { + xl(0) = x1; + xl(1) = x0; + } + if (y0 < y1) + { + yl(0) = y0; + yl(1) = y1; + } + else + { + yl(0) = y1; + yl(1) = y0; + } + ap.zoom (xl, yl); } - if (y0 < y1) - { - yl(0) = y0; - yl(1) = y1; - } - else - { - yl(0) = y1; - yl(1) = y0; - } - ap.zoom (xl, yl); mark_modified (); } } @@ -2036,7 +2043,7 @@ } return retval; -#else +#else error ("mouse_wheel_zoom: not available without OpenGL and FLTK libraries"); return octave_value (); #endif