Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    patches for missing field references in cellMouseDown and rowClick

    Hi there, we received an automated report of missing field references when a user clicks a button to change their grid view state. We haven't been able to recreate but the following common-sense checks to ensure that field is not null seem reasonable and hopefully, you can add these to the framework:

    Code:
             isc.ListGrid.getPrototype().addProperties({
    
                 $29w: function isc_ListGrid__cellMouseDown(_1, _2, _3) {
    
                     var _4 = this.getField(this.getLocalFieldNum(_3));
                     var _5;
                     //added check for _4
                     if (_4 && _4.cellMouseDown) {
                         if (_4.cellMouseDown(this, _1, _2, _3) == false) return false
                     }
                 },
    
    
                 rowClick: function isc_ListGrid_rowClick(_1, _2, _3, _4) {
    
                     this.$31q = _2;
                     var _1 = this.getCellRecord(_2, _3),
                         _5 = this.fields[_3];
                     if (Array.isLoading(_1)) return;
                     var _6 = this.getCellValue(_1, _2, _3);
                     var _7 = this.getRawCellValue(_1, _2, _3);
                     if (_1 != null && _1.$52e) {
                         if (this.canCollapseGroup == false) return;
                         if (_4) {
                             var _8 = isc.EH.getKey();
                             if (_8 != "Space" && _8 != "Enter") return
                         }
                         if (this.canSelectGroups && this.isCheckboxField(_5)) {
                             return
                         }
                         if (!this.collapseGroupOnRowClick) {
                             var _9 = this.getEventPart();
                             if (!_9 || _9.part != "opener") return
                         }
                         var _10 = this,
                             _11 = _1;
                         if (this.getEditRow() != null) {
                             if (this.autoSaveEdits) {
                                 var _12 = this.saveAllEdits(null, function() {
                                     _10.toggleFolder(_11)
                                 });
                                 if (_12) return
                             } else {
                                 this.storeUpdatedEditorValue()
                             }
                         }
                         this.toggleFolder(_1);
                         return
                     }
                     //check for _5
                     if (_5 && _5.valueIconClick != null && !_4) {
                         var _9 = this.getEventPart();
                         if (_9 && _9.part == "valueicon") {
                             isc.Func.replaceWithMethod(_5, "valueIconClick", "viewer,record,recordNum,field,rawValue,editor");
                             var _13 = _5.valueIconClick(this, _1, _2, _5, _7, null);
                             if (_13 == false) return false
                         }
                     }
                     //check for _5
                     if (_5 && _5.recordClick && !(_4 && _5.keyboardFiresRecordClick == false)) {
                         isc.Func.replaceWithMethod(_5, "recordClick", "viewer,record,recordNum,field,fieldNum,value,rawValue");
                         var _13 = _5.recordClick(this, _1, _2, _5, _3, _6, _7);
                         if (_13 == false) return false
                     }
                     if (this.recordClick) {
                         if (this.onRecordClick(this, _1, _2, _5, _3, _6, _7) == false)
                             return false;
                         if (this.recordClick(this, _1, _2, _5, _3, _6, _7) == false)
                             return false
                     }
                     var _14 = this.canEdit != false && (this.editEvent == isc.EH.CLICK || this.editOnFocus);
                     if (this.isCheckboxField(_5)) _14 = false;
                     //check for _5
                     if (_5 &&_5.canToggle && this.canEditCell(_2, _3) && this.shouldToggle(_5, _4)) {
                         var _15 = this.getEditorValueMap(_5, this.getEditedRecord(_2, _3));
                         if (_15 == null && isc.SimpleType.getBaseType(_5.type) == this.$g2) {
                             _15 = [true, false]
                         }
                         if (_15 != null) {
                             if (!isc.isAn.Array(_15)) _15 = isc.getKeys(_15);
                             if (_15.length > 1) {
                                 var _16 = this.getFieldName(_3),
                                     _17 = this.getEditedCell(_2, _3),
                                     _18 = _15.indexOf(_17);
                                 _18 += 1;
                                 if (_18 >= _15.length) _18 = 0;
                                 var _19 = _17;
                                 _17 = _15[_18];
                                 var _20;
                                 if (_5.change != null) {
                                     this.logInfo("canToggle firing specified field.change() event directly", "gridEdit");
                                     _20 = this.fireCallback(_5.change, "form,item,value,oldValue", [null, null, _17, _19]) == false
                                 }
                                 if (!_20) {
                                     if (!_14 && this.autoSaveEdits) {
                                         this.setEditValue(_2, _3, _17, true, false)
                                     } else {
                                         this.setEditValue(_2, _3, _17)
                                     }
                                     if (_5.changed != null) {
                                         this.logInfo("canToggle firing specified field.changed() event directly", "gridEdit");
                                         this.fireCallback(_5.changed, "form,item,value", [null, null, _17])
                                     }
                                     if (this.autoSaveEdits) {
                                         this.saveEdits(null, null, _2, _3)
                                     } else {
                                         this.validateCell(_2, _3)
                                     }
                                 }
                             }
                         }
                     }
                     if (_14) {
                         if (this.handleEditCellEvent(_2, _3, isc.ListGrid.CLICK) == true) {
                             return true
                         }
                         if (_4) {
                             for (var i = 0; i < this.fields.length; i++) {
                                 if (i == _3) continue;
                                 if (this.handleEditCellEvent(_2, i, isc.ListGrid.CLICK) == true) {
                                     return true
                                 }
                             }
                         }
                     }
                 }
    })

    #2
    This is yet another set of "field may be null" pseudo-patches from you without a test case. Sorry, we can't accept more of these, not unless you have a test case showing that there's a framework bug here - null guards for impossible situations may just mask actual problems and make them tougher to find in the future.

    Comment

    Working...
    X