Followup: avoid dereference null pointer (#971)
Changing _root->find_clicked(..) to just find_clicked(..) includes the check of _root for NULL, which is probably better than doing a repeat explicit check and early exit.
This commit is contained in:
parent
324fcfcb62
commit
549688598f
@ -383,8 +383,7 @@ int Fl_Tree::handle(int e) {
|
||||
case FL_PUSH: { // clicked on tree
|
||||
last_my = Fl::event_y(); // save for dragging direction..
|
||||
if (Fl::visible_focus() && handle(FL_FOCUS)) Fl::focus(this);
|
||||
if ( ! _root ) return(ret); // issue #971
|
||||
Fl_Tree_Item *item = _root->find_clicked(_prefs, 0);
|
||||
Fl_Tree_Item *item = find_clicked(0);
|
||||
// Tell FL_DRAG what was pushed
|
||||
_lastpushed = item ? item->event_on_collapse_icon(_prefs) ? PUSHED_OPEN_CLOSE // open/close icon clicked
|
||||
: item->event_on_user_icon(_prefs) ? PUSHED_USER_ICON // usericon clicked
|
||||
@ -471,7 +470,7 @@ int Fl_Tree::handle(int e) {
|
||||
// During drag, only interested in left-mouse operations.
|
||||
//
|
||||
if ( Fl::event_button() != FL_LEFT_MOUSE ) break;
|
||||
Fl_Tree_Item *item = _root->find_clicked(_prefs, 1); // item we're on, vertically
|
||||
Fl_Tree_Item *item = find_clicked(1); // item we're on, vertically
|
||||
if ( !item ) break; // not near item? ignore drag event
|
||||
ret |= 1; // acknowledge event
|
||||
if (_prefs.selectmode() != FL_TREE_SELECT_SINGLE_DRAGGABLE)
|
||||
@ -506,7 +505,7 @@ int Fl_Tree::handle(int e) {
|
||||
case FL_RELEASE:
|
||||
if (_prefs.selectmode() == FL_TREE_SELECT_SINGLE_DRAGGABLE &&
|
||||
Fl::event_button() == FL_LEFT_MOUSE) {
|
||||
Fl_Tree_Item *item = _root->find_clicked(_prefs, 1); // item mouse is over (vertically)
|
||||
Fl_Tree_Item *item = find_clicked(1); // item mouse is over (vertically)
|
||||
if (item && // mouse over valid item?
|
||||
_lastselect && // item being dragged is valid?
|
||||
item != _lastselect) { // item we're over not same as drag item?
|
||||
@ -749,7 +748,7 @@ void Fl_Tree::draw() {
|
||||
if (_prefs.selectmode() == FL_TREE_SELECT_SINGLE_DRAGGABLE && // drag mode?
|
||||
Fl::pushed() == this) { // item clicked is the one we're drawing?
|
||||
|
||||
Fl_Tree_Item *item = _root->find_clicked(_prefs, 1); // item we're on, vertically
|
||||
Fl_Tree_Item *item = find_clicked(1); // item we're on, vertically
|
||||
if (item && // we're over a valid item?
|
||||
item != _item_focus) { // item doesn't have keyboard focus?
|
||||
// Are we dropping above or below the target item?
|
||||
|
Loading…
Reference in New Issue
Block a user