Hi Cyrille,

As I could see, the this._clearCache flag can be set to true but will be 
handled on the next _onRowDataLoaded call. This causes in a timing problem, 
which should be solved. Could you please open a bug and provide us with a more 
dedicated example code on playground? (use tiny url button)

Regards
Mustafa Sak

Applications & Integration

1&1 Internet AG
Ernst-Frey-Straße 10
DE-76135 Karlsruhe

Von: cyrille rigault [mailto:[email protected]]
Gesendet: Montag, 18. Februar 2013 15:48
An: [email protected]
Betreff: [qooxdoo-devel] possible qx.ui.table.model.Remote bug(s)

Hello,

I think I found 2 bugs in qx.ui.table.model.Remote.

1) the first one is that the lastRow field sent in the dataChanged event when 
data is received exceed 1 block size.

2) the second one appears after qooxdoo 2.0, where the protected variable 
_clearCache has been added.
the problem appears in the following sequence:

 - loadData() data1
 -> receive data1 count
 - prefetch data1
 - loadData() data2
 -> receive data2 count
 - prefetch data2
 -> receive data prefetch data1  (ignored as obsolete)
 -> received data prefetch data2 => bug: firstRow=-20 (negative)

when putting this._clearCache into comment in reloadData(), it works fine (as 
in qooxdoo2.0)

the problem can be tested using the following simulation code in the playground 
(see logs in console)

Thank you to tell me if this is a bug, or if I am not correctly using the class.

Cyrille

----------------

/**
 */
qx.Class.define( "RemoteData", {
  extend : qx.ui.table.model.Remote,

  construct : function() {
    this.base(arguments);

    this.__count = 0;
    this.__delay = 1000;
    this.__id = 0;

    this.set({
      blockSize : 20,
      maxCachedBlockCount : 5
    });
  },

  members : {
    __count : null,  // how much data is sent from the "server"
    __value : null,  // data value (string) sent from the "server"
    __delay : null,  // delay in ms between request and "server" reply
    __id : null,     // sequence id of count-prefetch...


    /**
     * Ask for remote data : value, count, and delay used for simulation
     */
    loadData : function( value, count, delay) {
      this.__id++;
      this.__count = count;
      this.__value = value;
      this.__delay = delay;
      this.clearCache();
      this.reloadData();
    },


    /**
     * Set server delay in ms (for simulation)
     */
    setDelay : function( delay) {
      this.__delay = delay;
    },


    // overriden
    _loadRowCount : function() {
console.log( "_loadRowCount delay="+this.__delay);
      // should ask server data count ..

      // simulate server reply delay
      qx.util.TimerManager.getInstance().start( function( userData, timerId) {
console.log( "===> row count "+this.__count);

        // check for obsolete count reply
        var count = (userData === this.__id) ? this.__count : null;
        this._onRowCountLoaded( count); // fires dataChanged
      }, 0, this, this.__id, this.__delay);
    },


    // overriden
    _loadRowData : function( first, last) {
console.log( "_loadRowData "+first+" "+last+" delay="+this.__delay);
      var value = this.__value,
          count = this.__count;

      // should ask server data ...

      // simulate server reply delay
      qx.util.TimerManager.getInstance().start( function( userData, timerId) {
console.log( "===> row data "+first+" "+last);
        var arr = [];
        for (var i=first; i<Math.min( last+1, count); i++) {
          arr.push( value+" "+i);
        }
console.log( arr);
        // check for obsolete data
        if (userData !== this.__id) {
          arr = null;
        }
        this._onRowDataLoaded( arr); // fires dataChanged
      }, 0, this, this.__id, this.__delay);
    }
  }
});

/**
 */

var doc = this.getRoot();
var test1 = new qx.ui.form.Button("test1");
doc.add( test1, {left: 100, top: 50});


/*
 Test sequence:
 - loadData() data1
 -> receive data1 count
 - prefetch 1.1
 - loadData() data2
 -> receive data2 count
 - prefetch 2.1
 -> receive data prefetch 1.1  (ignored as obsolete)
 -> received data prefetch 2.1 => bug: first=-20 last=39 (à la place de 80 139)
*/
test1.addListener("execute", function(e) {
  var remoteData = new RemoteData();
  var state = 0;
  var failed = false;
  var count;

  remoteData.addListener( "dataChanged", function(e) {
    var info = e.getData(),
    firstRow = info.firstRow,
    lastRow = info.lastRow;
    console.log( "DATA CHANGED : first "+firstRow+" last "+lastRow);
    switch (state) {
      // receive data1 count
      case 0:
        count = remoteData.getRowCount();
        failed |= ((count !== 1000) || (firstRow !== 0) || (lastRow !== 999));
        console.log( "count="+count);
        remoteData.setDelay( 1500);
        remoteData.prefetchRows( 0, 19);            // prefetch data1 0..19
        remoteData.loadData( "world", 500, 1000);   // load data2
        console.log( failed ? "FAILED" : "OK");
        break;
      // receive data2 count
      case 1:
        count = remoteData.getRowCount();
        failed |= ((count !== 500) || (firstRow !== 0) || (lastRow !== 499));
        console.log( "count="+count);
        remoteData.prefetchRows( 100, 119);         // prefetch data2 100...119
        console.log( failed ? "FAILED" : "OK");
        break;
      case 2:
        failed |= ((firstRow !== 80) || (lastRow !== 139) || 
(remoteData.getRowData(80) !== "world 80") || (remoteData.getRowData(139) !== 
"world 139"));
        console.log( failed ? "FAILED" : "OK");
        console.log( failed ? "===== FAILED =====" : "===== OK =====");
        break;
      }
    ++state;
  }, this);
  remoteData.loadData( "hello", 1000, 1000);          // load data1
}, this);
------------------------------------------------------------------------------
The Go Parallel Website, sponsored by Intel - in partnership with Geeknet, 
is your hub for all things parallel software development, from weekly thought 
leadership blogs to news, videos, case studies, tutorials, tech docs, 
whitepapers, evaluation guides, and opinion stories. Check out the most 
recent posts - join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to